Hi, I'm trying to set up an image gallery which automatically displays the images that users have uploaded to my database (in the form of the images' url).
I've managed to get as far as displaying some images in a table with the code below (which pulls the images from the table)
However, I have some questions that as yet noone could help me with...
1. The script below requires me to set up separate pages to limit the table size, and has no idea on how many images its loading. The pics-per-row is only set up with the LIMIT function which means I would daily have to create new pages/adjust LIMIT values to cope with the increase in pictures.
So how can I automatically with php/mySQL create a page (and link to it) when say the table contains 30 images and likewise, how can I specify the max-pics per row/column?
- I've included a link to a file that as just doesnt exist (full_photo.php). The only reason for this is that I dont know the command to retrieve a specific row (i.e. the full link would be something like this - http://www.domain.com/testing/full_photo.php?id=5. So How does full_photo.php grab and display only the image with id number 5?
pulltest.php (brings the images from MySQL db)
<html>
<body bgcolor="#374280">
<?
include("config.inc.php");
// connect to MySQL
$db = mysql_connect($dbhost,$dbuser,$dbpasswd);
mysql_select_db($dbname);
$photo0 = mysql_query("SELECT * FROM testImages LIMIT 1, 5");
$photo1 = mysql_query("SELECT * FROM testImages LIMIT 6, 10");
$photo2 = mysql_query("SELECT * FROM testImages LIMIT 11, 15");
$photo3 = mysql_query("SELECT * FROM testImages LIMIT 16, 20");
echo "<table width=400 cellpadding=0 cellspacing=5 border=0 bgcolor=#242C53>\n";
echo "<tr>\n";
while($a_row=mysql_fetch_array($photo0)) {
print "<td width=100><a href='full_photo.php?id=" . $a_row["id"] . "'><img src=" . $a_row["testing"] . " width=100 height=100 border=0></a></td>\n";
}
echo "<tr>\n";
while($a_row=mysql_fetch_array($photo1)) {
print "<td width=100><a href='full_photo.php?id=" . $a_row["id"] . "'><img src=" . $a_row["testing"] . " width=100 height=100 border=0></a></td>\n";
}
echo "<tr>\n";
while($a_row=mysql_fetch_array($photo2)) {
print "<td width=100><a href='full_photo.php?id=" . $a_row["id"] . "'><img src=" . $a_row["testing"] . " width=100 height=100 border=0></a></td>\n";
}
echo "<tr>\n";
while($a_row=mysql_fetch_array($photo3)) {
print "<td width=100><a href='full_photo.php?id=" . $a_row["id"] . "'><img src=" . $a_row["testing"] . " width=100 height=100 border=0></a></td>\n";
}
echo "</table>\n"
?>
</body>
</html>