First of all I would like to say how good this site is. This is the first time I enter it and it's indeed full of helpful lines.
Here's my problem: I'm building a pagination code for an image gallery in my website. I have several galleries each one with a different amount of pictures, so I need it in order to reduce weight on pages, performance, etc.
So if I am on my index of all the existing galleries I would have something like this:
Beatles Concert
(LINK as http://www.mywebsite.com/display.php?gallery=Beatles%20Concert)
Led Zeppelin (LINK......)
and so on...
When I click the link I get to the first page... where it shows the limit of images I introduced. But when I click to advance to the next page it takes me to a link where I have no images, no connection at all with the database.
I tried modifying parts of it so it looked like
http://www.mywebsite.com/display.php?gallery=Beatles%20Concert&page=1 and changed page to 2 or so on but the result would be a page exactly as the initial page.
My code is inside a file where I have all the rest of the functions of the image gallery... and the extract is as follows:
<?php
// etc.. bunch of functions
function display_content($event)
{
$conn = db_connect();
$s_sql = "select * from imagesgallery where event='$event'";
$s_result = mysql_query($s_sql, $conn);
if (mysql_num_rows($s_result))
{
$s = mysql_fetch_array($s_result);
}
echo "<p align='center'><font face='arial' size=4><b>Image Gallery for ".$event."</b></font></p>";
if(isSet($search)){
$d_array = explode("|",$search);
$EVENTYEAR = $d_array[0];
$EVENTDATE = $d_array[1];
}
$limit = 8;
$query_count = "SELECT * FROM imagesdb where evento='$event' order by image asc";
$search = $EVENTYEAR."|".$EVENTDATE;
$search_display = $EVENTYEAR." AND ".$EVENTDATE;
$result_count = mysql_query($query_count);
$totalrows = mysql_num_rows($result_count);
if(empty($page))
$page = 1;
$limitvalue = $page * $limit - ($limit);
$query = "SELECT * FROM imagesdb where evento='$event' order by image asc LIMIT $limitvalue, $limit ";
$result = mysql_query($query) or die("Error: " . mysql_error());
$count_result = mysql_num_rows($result);
// Display links at the top to indicate current page and number of pages displayed
$numofpages = ceil($totalrows / $limit);
echo "<br><p><b>$totalrows</b> result(s) for: \"$search_display\"</p>";
$from=$limit*$page-$limit+1;
$to=$from + $count_result-1;
// start 123 next>> table
echo "<table align=\"center\" width=\"90%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
<tr><td width=\"50%\" bgcolor=\"$bg_colour\" align=\"left\">";if($numofpages>1){echo"Showing: $from - $to</td><td width=\"50%\" bgcolor=\"$bg_colour\" align=\"right\"><b>Go to:</b> ";}
// display previous link if page is not 1
if($page != 1){
$pageprev = $page - 1;
echo("<a href=\"$PHP_SELF?page=$pageprev&search=$search\"><< PREV</a> ");
}
// display page nos if not 1
for($i = 1; $i <= $numofpages; $i++){
if($numofpages>1){
if($i == $page)
echo(" ".$i." ");
else
echo(" <a href=\"$PHP_SELF?page=$i&search=$search\">$i</a> ");
}}
// display next page link if there is more than one
if(($totalrows - ($limit * $page)) > 0){
$pagenext = $page + 1;
echo("<a href=\"$PHP_SELF?page=$pagenext&search=$search\">NEXT>></a>");
}
// end 123 next>> table
echo"</td></tr></table><br>";
while($row=mysql_fetch_array($result)){
if (($row["DAY"]) == "00"){
echo "<table bgcolor=#FFFEEF border=0 cellpadding=2 cellspacing=0 style=border-collapse: collapse bordercolor=#111111 width=100%>
<tr><td align=left width=20% valign=top><b><font face=Verdana size=2 color=#800080>{$row['image']}-{$row['MONTH']}</font></b></td>
<td align=justify width=80% valign=top><font face=Verdana size=2 color=#000000>{$row['EVENTTEXT']}</td></table>";
}else{
echo "<table bgcolor=#FFFEEF border=0 cellpadding=2 cellspacing=0 style=border-collapse: collapse bordercolor=#111111 width=100%>
<tr><td align=left width=20% valign=top><b><font face=Verdana size=2 color=#800080>{$row['image']}</font></b></td>
<td align=justify width=80% valign=top><font face=Verdana size=2 color=#000000>{$row['EVENTTEXT']}</td></table>";
}
echo ("<p>");
echo ("<p>");
}
echo ("<p>");
echo ("<p>");
}
?>
Thanks in advance...