Jump to content

[SOLVED] not sure how to explain in a subject.. but i need help


richiec

Recommended Posts

http://fearedwarlords.dks-gfx.com/timeframe/

 

 

ok, each image has its own row in the sql table which has the time, date and name also (for the mouse over)

 

But..

 

I need them to be next to eachother insted of on a different line on the site.. this is my current code..

 


$result=mysql_query($query) or die(hmm);
$num = mysql_num_rows($result);
$i=0;
while ($i < $num) {

$name = mysql_result($result,$i,"name");
$date = mysql_result($result,$i,"date");
$time =mysql_result($result,$i,"time");
$image =mysql_result($result,$i,"image");

$i++;

echo "<div align=\"center\"><a href=\"#\" target=\"_parent\" title=\"$name is due on the $date at $time\"> <img src=\"$image\" /><span class=\"style1\"></span></div>
";
}

 

any ideas how i can get the images to display next to eachother insted of on a new line for each image?

Link to comment
Share on other sites

Try this:

 

<?php

$result=mysql_query($query) or die(hmm);
$num = mysql_num_rows($result);
$i=0;

echo "<div align=\"center\">";

while ($i < $num) {

$name = mysql_result($result,$i,"name");
$date = mysql_result($result,$i,"date");
$time =mysql_result($result,$i,"time");
$image =mysql_result($result,$i,"image");

$i++;

echo "
<a href=\"#\" target=\"_parent\" title=\"$name is due on the $date at $time\"> 
<img src=\"$image\" />";
}

echo '</div>';

?>

 

That will spit them all out on the same line. Did you want it to start a new line after X amount of images displayed?

Link to comment
Share on other sites

<?php

$result=mysql_query($query) or die(hmm);
$num = mysql_num_rows($result);
$i=0;

echo "<div align=\"center\">";

$count = 1;
while ($i < $num) {

$name = mysql_result($result,$i,"name");
$date = mysql_result($result,$i,"date");
$time =mysql_result($result,$i,"time");
$image =mysql_result($result,$i,"image");

if ($count == 5){ //This is how columns you would like
    echo '<br>';
    $count = 0;
}

echo "
<a href=\"#\" target=\"_parent\" title=\"$name is due on the $date at $time\"> 
<img src=\"$image\" />";

$count++;
$i++;
}

echo '</div>';

?>

 

This will make a new line after every 5 images, you can change the number 5 to whatever you need.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.