You are here: Problems outputting to a 3 column table in order to crate an image gallery « PHP Programming Language « IT news, forums, messages
Problems outputting to a 3 column table in order to crate an image gallery

Posted by ste on 04/29/06 04:12

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?imagetype=landscape (i.e. to access the landscape
gallery).

Thank you for any help,

Ste


<?php
include("my_db_login.inc");

$connection = mysql_connect($host,$user,$password) or die ("couldn't connect
to server");
$db = mysql_select_db($database,$connection) or die ("Couldn't select
database");

$title = "Gallery";
$query = "SELECT * FROM mydatabase WHERE imagetype =
\"{$_GET['imagetype']}\"";
$result = mysql_query($query) or die ("Couldn't execute query.");

echo "<h2>$title</h2>";
echo "<table>";
echo "<tbody>";

while ($row = mysql_fetch_array($result))

{
extract($row);
echo "<tr>";
echo "<td><img src=\"$imagelocation\" />\n
</td>\n";
}

echo "</tr>";
echo "</table>\n";
?>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация