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?

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?

<?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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.