<?php // Connects to your Database mysql_connect("*****", "*****", "*****") or die(mysql_error()); mysql_select_db("*****") or die ("Unable to connect to MySQL"); // How many pictures to display on each page. $picsperpage = 12; // How many pictures to display per row. $picsperrow = 4; // images $thumb ='/photos/'.$info['date'].'/thumbs/'.$info['thumb']; $url ='/photos/'.$info['date'].'/'.$info['url']; // If the page number is set... if(isset($_GET['p'])) { // $page is now the page number. $page = $_GET['p']; } else { // Otherwise the page is 1. $page = 1; } // What the starting number will be for the query. $start = ($page - 1) * $picsperpage; // Counts all of the rows in the table. $res= @mysql_query("SELECT COUNT(id) AS numrows FROM photos") or die("Sorry, but there was an error retrieving the gallery."); // Gets the number of rows from the array. $fetchres = @mysql_fetch_array($res, MYSQL_ASSOC) or die("Sorry, but there was an error retrieving the gallery."); $numrows = $fetchres['numrows']; // How many pages there will be (total pictures / # of pictures per page). $totalpages = ceil($numrows/$picsperpage); echo '<ul>'; // Echos our page numbers so that we can navigate. for($i=1; $i <= $totalpages; $i++) { if($i == $page) { // If it's the current page, don't make a link since we are already there. echo '<li>' . $i . '</i>'; } else { // Make all other pages links. echo '<li><a href="main.php?p=' . $i . '">' . $i . '</a></li>'; } } echo '</ul><br /> <div class="gallery">'; // Get all of the pictures for the current page. $allphotos = @mysql_query("SELECT * FROM photos LIMIT $start, $picsperpage") or die("Sorry, but there was an error retrieving the gallery."); // How many pictures there are right now. $rowcount = 0; // For each row in the gallery table... while ($row = @mysql_fetch_array($allphotos)) { // If $rowcount divided by $picsperrow has a remainder of 0... if (($rowcount % $picsperrow) == 0) { // Make a <br /> tag with a clear both style, so that there is a new row of images echo '<br style="clear: both;" />'; } // Displaying each image with this code. echo '<a href="' . $row['thumb']. '"><img src="' . $row['url']. '" /></a>'; // $rowcount + 1. $rowcount++; } // After all the images are done, end the div. echo '</div>'; ?>
echo '<a href="' . $row['thumb']. '"><img src="' . $row['url']. '" /></a>';
<a href="001.jpg"><img src="001.php" /></a>
<?php // Connects to your Database mysql_connect("***", "***", "***")or die(mysql_error()); mysql_select_db("***")or die ("Unable to connect to MySQL"); // How many pictures to display on each page. $picsperpage = 12; // How many pictures to display per row. $picsperrow = 4; // images $thumb ='/photos/'.$info['date'].'/thumbs/'.$info['thumb']; $url ='/photos/'.$info['date'].'/'.$info['url']; // If the page number is set... if(isset($_GET['p'])) { // $page is now the page number. $page = $_GET['p']; } else { // Otherwise the page is 1. $page = 1; } // What the starting number will be for the query. $start = ($page - 1) * $picsperpage; // Counts all of the rows in the table. $res= @mysql_query("SELECT COUNT(id) AS numrows FROM photos")or die("Sorry, but there was an error retrieving the gallery."); // Gets the number of rows from the array. $fetchres = @mysql_fetch_array($res, MYSQL_ASSOC)or die("Sorry, but there was an error retrieving the gallery."); $numrows = $fetchres['numrows']; // How many pages there will be (total pictures / # of pictures per page). $totalpages = ceil($numrows/$picsperpage); echo '<ul>'; // Echos our page numbers so that we can navigate. for($i=1; $i <= $totalpages; $i++) { if($i == $page) { // If it's the current page, don't make a link since we are already there. echo '<li>' . $i . '</i>'; } else { // Make all other pages links. echo '<li><a href="main.php?p=' . $i . '">' . $i . '</a></li>'; } } echo '</ul><br /> <div class="gallery">'; // Get all of the pictures for the current page. $allphotos = @mysql_query("SELECT * FROM photos LIMIT $start, $picsperpage")or die("Sorry, but there was an error retrieving the gallery."); // How many pictures there are right now. $rowcount = 0; // For each row in the gallery table... while ($row = @mysql_fetch_array($allphotos)) { // If $rowcount divided by $picsperrow has a remainder of 0... if (($rowcount % $picsperrow) == 0) { // Make a <br /> tag with a clear both style, so that there is a new row of images echo '<br style="clear: both;" />'; } // Displaying each image with this code. echo '<a href="' . $row['url'] . '"><img src="' . $row['thumb'] . '" /></a>'; // $rowcount + 1. $rowcount++; } // After all the images are done, end the div. echo '</div>'; ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Equine Focus</title> </head> <body> <?php // Connects to your Database mysql_connect("*****", "*****", "*****") or die(mysql_error()); mysql_select_db("*****") or die ("Unable to connect to MySQL"); // How many pictures to display on each page. $picsperpage = 12; // How many pictures to display per row. $picsperrow = 3; // images $thumb ='/photos/'.$info['date'].'/thumbs/'.$info['thumb']; $url ='/photos/'.$info['date'].'/'.$info['url']; // If the page number is set... if(isset($_GET['p'])) { // $page is now the page number. $page = $_GET['p']; } else { // Otherwise the page is 1. $page = 1; } // What the starting number will be for the query. $start = ($page - 1) * $picsperpage; // Counts all of the rows in the table. $res= @mysql_query("SELECT COUNT(id) AS numrows FROM photos") or die("Sorry, but there was an error retrieving the gallery."); // Gets the number of rows from the array. $fetchres = @mysql_fetch_array($res, MYSQL_ASSOC) or die("Sorry, but there was an error retrieving the gallery."); $numrows = $fetchres['numrows']; // How many pages there will be (total pictures / # of pictures per page). $totalpages = ceil($numrows/$picsperpage); echo '<ul>'; // Echos our page numbers so that we can navigate. for($i=1; $i <= $totalpages; $i++) { if($i == $page) { // If it's the current page, don't make a link since we are already there. echo '<li>' . $i . '</i>'; } else { // Make all other pages links. echo '<li><a href="main.php?p=' . $i . '">' . $i . '</a></li>'; } } echo '</ul><br /> <div class="gallery">'; // Get all of the pictures for the current page. $allphotos = @mysql_query("SELECT * FROM photos LIMIT $start, $picsperpage") or die("Sorry, but there was an error retrieving the gallery."); // How many pictures there are right now. $rowcount = 0; // For each row in the gallery table... while ($row = @mysql_fetch_array($allphotos)) { // If $rowcount divided by $picsperrow has a remainder of 0... if (($rowcount % $picsperrow) == 0) { // Make a <br /> tag with a clear both style, so that there is a new row of images echo '<br style="clear: both;" />'; } // Displaying each image with this code. echo '<a href="' . $url. '"><img src="' . $thumb. '" /></a>'; // $rowcount + 1. $rowcount++; } // After all the images are done, end the div. echo '</div>'; ?>
Can you post the rest of your script?
I have setup a table on my database and a slightly modified script on the server and it works for me.
Here's the edited code
php Syntax (Toggle Plain Text)
<?php // Connects to your Database mysql_connect("***", "***", "***")or die(mysql_error()); mysql_select_db("***")or die ("Unable to connect to MySQL"); // How many pictures to display on each page. $picsperpage = 12; // How many pictures to display per row. $picsperrow = 4; // images $thumb ='/photos/'.$info['date'].'/thumbs/'.$info['thumb']; $url ='/photos/'.$info['date'].'/'.$info['url']; // If the page number is set... if(isset($_GET['p'])) { // $page is now the page number. $page = $_GET['p']; } else { // Otherwise the page is 1. $page = 1; } // What the starting number will be for the query. $start = ($page - 1) * $picsperpage; // Counts all of the rows in the table. $res= @mysql_query("SELECT COUNT(id) AS numrows FROM photos")or die("Sorry, but there was an error retrieving the gallery."); // Gets the number of rows from the array. $fetchres = @mysql_fetch_array($res, MYSQL_ASSOC)or die("Sorry, but there was an error retrieving the gallery."); $numrows = $fetchres['numrows']; // How many pages there will be (total pictures / # of pictures per page). $totalpages = ceil($numrows/$picsperpage); echo '<ul>'; // Echos our page numbers so that we can navigate. for($i=1; $i <= $totalpages; $i++) { if($i == $page) { // If it's the current page, don't make a link since we are already there. echo '<li>' . $i . '</i>'; } else { // Make all other pages links. echo '<li><a href="main.php?p=' . $i . '">' . $i . '</a></li>'; } } echo '</ul><br /> <div class="gallery">'; // Get all of the pictures for the current page. $allphotos = @mysql_query("SELECT * FROM photos LIMIT $start, $picsperpage")or die("Sorry, but there was an error retrieving the gallery."); // How many pictures there are right now. $rowcount = 0; // For each row in the gallery table... while ($row = @mysql_fetch_array($allphotos)) { // If $rowcount divided by $picsperrow has a remainder of 0... if (($rowcount % $picsperrow) == 0) { // Make a <br /> tag with a clear both style, so that there is a new row of images echo '<br style="clear: both;" />'; } // Displaying each image with this code. echo '<a href="' . $row['url'] . '"><img src="' . $row['thumb'] . '" /></a>'; // $rowcount + 1. $rowcount++; } // After all the images are done, end the div. echo '</div>'; ?>
See it here: clicky
// images $thumb ='/photos/'.$info['date'].'/thumbs/'.$info['thumb']; $url ='/photos/'.$info['date'].'/'.$info['url'];
// Displaying each image with this code. echo '<a href="' . $url. '"><img src="' . $thumb. '" /></a>';
// Image Declarations $thumb ="/photos/" . $row['date'] . "/thumbs/" . $row['thumb']; $url ="/photos/" . $row['date'] . "/" . $row['url']; // Displaying each image with this code. echo '<a href="' . $url. '"><img src="' . $thumb. '" /></a>';
| DaniWeb Message | |
| Cancel Changes | |