Displaying Images Side by Side

What I’m trying to do is display images side by side using mysql_fetch_array, because there’s more involved than just images. I want to use mysql, rather than arrays. I saw a function for it where it makes a sort of matrix like this:

1 2
3 4
5 6
7 8
9 10

I know there’s a way of doing this, I just forgot how. Any help?

Update:

This is what I tried, and it didn’t work.
[php]while($row = mysql_fetch_array($sql))
{
echo “

<td class=“collection” align=center>
”.$row[morph]."
".$row[species]."";
$id = $row[id];
if($id % 2 != 0)
{
echo “
”;
}
else
{
echo " ";
}
}[/php]

You stored images in a database? That is usually not suggested. Unless they are just small like icons.
Usually, you just store the names and locations as text and then put them on the page using IMAGE tags.

Anyways, if your images ARE in your database, this might work for you. (Basically your code with tweaks!)
[php]
while($row = mysql_fetch_array($sql))
{
echo “

”;
echo “<td class=“collection” align=center>”;
echo “
” . $row[morph] . “
” . $row[species] . “”;
if(next($row[id]))
{
echo “<td class=“collection” align=center>”;
echo “
” . $row[morph] . “
” . $row[species] . “”;
echo “”;
} else {
echo “”;
}
}
[/php]
This uses a trick that is easier to use than odd/even rows and faster! It displays one square, then pushes the array to the next position and displays the second square. If that square is empty, it ends the row.
Should work for you…
Sponsor our Newsletter | Privacy Policy | Terms of Service