Web Hosting Talk







View Full Version : MySQL output in a table.


aingaran
01-19-2004, 10:58 AM
I was wondering if someone can help me with my code.
In my db, i have records of image paths...(where images have been uploaded) i want to create a gallery.

so, i do the following:

Here, this works...1 image per row...


$query = "SELECT imgpath WHERE username = '$username'";
$result = mysql_query($query) or die (mysql_error()):
(while $album = mysql_fetch_array($result))
{
print "<tr><td><img src=\"$album[imgpath]\"></td></tr>";
}


I want 2 images per row...Instead of 1 image per row.
Can someone please help me with the code for that?


$query = "SELECT imgpath WHERE username = '$username'";
$result = mysql_query($query) or die (mysql_error()):
(while $album = mysql_fetch_array($result))
{
print "<tr><td><img src=\"$album[imgpath]\"></td><td><img src=\"$album[imgpath]\"></td></tr>";
}

StreetWarz
01-19-2004, 11:06 AM
$query = "SELECT imgpath WHERE username = '$username'";
$result = mysql_query($query) or die (mysql_error()):
$a = 0;
while $album = mysql_fetch_array($result) {
$a = $a + 1;
if ($a == 1) {
print "<tr><td><img src=\"$album[imgpath]\"> ";
} else {
$a = 0;
print "<img src=\"$album[imgpath]\"></td></tr>";
}
}


Something like this.. :)