Hi there,
I'm trying to query a MySQL database (containing image data) and to output
the results in a HTML table of 3 columns wide (and however many rows it
takes) in order to create a basic thumbnail gallery.
I can query and output the data as a single column table, but I'm having
problems filling up a 3 column table (with different images, looping
continuously until the end).
I would appreciate it if someone could take a look at the code below and
point me in the right direction or suggest any extra lines of code which
would finish the job?
The code below puts an image on each row, instead of filling up 3 columns on
each row with a different image.
I open this gallery by going to
mywebsite.com/gallery.php?ima getype=landscap e (i.e. to access the landscape
gallery).
Thank you for any help,
Ste
<?php
include("my_db_ login.inc");
$connection = mysql_connect($ host,$user,$pas sword) or die ("couldn't connect
to server");
$db = mysql_select_db ($database,$con nection) or die ("Couldn't select
database");
$title = "Gallery";
$query = "SELECT * FROM mydatabase WHERE imagetype =
\"{$_GET['imagetype']}\"";
$result = mysql_query($qu ery) or die ("Couldn't execute query.");
echo "<h2>$title </h2>";
echo "<table>";
echo "<tbody>";
while ($row = mysql_fetch_arr ay($result))
{
extract($row);
echo "<tr>";
echo "<td><img src=\"$imageloc ation\" />\n
</td>\n";
}
echo "</tr>";
echo "</table>\n";
?>