I have been working on this for a while now and have had no luck. I have tried this code on 2 servers and they both render the same results: everything loads up to the title and description.

Does anyone know what could possibly be the problem and help me get this working?

Code:

<?php
//db connector
$aid = mysql_real_escape_string($_GET['aid'], $con);
// create an array to set page-level variables
$page = array();
$page['title'] = '';
// include the page header
include('includes/template/header.php');
//$aid = '1';

//page starts here
echo "<div align='center'>";
echo "<div class='wrapper_photo'>";
//Title and description
$select1 = ("SELECT * FROM photo_albums WHERE aid = '$aid' ");
$result1 = mysql_query($select1) or die(mysql_error());
while($row = mysql_fetch_array($result1)) {
	echo "<h3 align='left'>".$row['atitle']."</h3>"
         ."<p align='left'>".$row['description']."</p>";
}
//Nothing loads from here on....

// find out how many rows are in the table 
$sql = "SELECT COUNT(*) FROM pictures WHERE aid = $aid";
$result = mysql_query($sql, $conn) or trigger_error("SQL", E_USER_ERROR);
$r = mysql_fetch_row($result);
$numrows = $r[0];

// number of rows to show per page
$rowsperpage = 2;
// find out total pages
$totalpages = ceil($numrows / $rowsperpage);

// get the current page or set a default
if (isset($_GET['currentpage']) && is_numeric($_GET['currentpage'])) {
   // cast var as int
   $currentpage = (int) $_GET['currentpage'];
} else {
   // default page num
   $currentpage = 1;
} // end if

// if current page is greater than total pages...
if ($currentpage > $totalpages) {
   // set current page to last page
   $currentpage = $totalpages;
} // end if
// if current page is less than first page...
if ($currentpage < 1) {
   // set current page to first page
   $currentpage = 1;
} // end if

// the offset of the list, based on current page 
$offset = ($currentpage - 1) * $rowsperpage;

$sql = "SELECT * FROM pictures WHERE aid = $aid ORDER BY pid ASC LIMIT $offset, $rowsperpage";
$result = mysql_query($sql, $conn) or trigger_error("SQL", E_USER_ERROR);

//gallery thumbs
//$select = ("SELECT * FROM pictures WHERE aid = '$aid' ORDER BY pid ASC ");
//$result = mysql_query($select) or die(mysql_error());

echo "<div class='photoWrap'>";

while ($list = mysql_fetch_assoc($result)) {

echo "<div class='photoThumb'>"
   ."<a href='".$row['filepath'].$row['filename']."'rel='lightbox[".$aid."]'>"
   //."<a href='".$filename."'>"
   ."<img border='0' width='100px' src='".$row['filepath'].$row['filename']."' />"
   //."<img src='".$filename."' rel='lightbox['".$aid."']' border='0' width='100px' />"
   ."</a><br/></div>";
}
echo "</div>";

/******  build the pagination links ****/
// range of num links to show
$range = 3;

// if not on page 1, don't show back links
if ($currentpage > 1) {
   // show << link to go back to page 1
   echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=1'><<</a> ";
   // get previous page num
   $prevpage = $currentpage - 1;
   // show < link to go back to 1 page
   echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$prevpage'><</a> ";
} // end if 

// loop to show links to range of pages around current page
for ($x = ($currentpage - $range); $x < (($currentpage + $range) + 1); $x++) {
   // if it's a valid page number...
   if (($x > 0) && ($x <= $totalpages)) {
      // if we're on current page...
      if ($x == $currentpage) {
         // 'highlight' it but don't make a link
         echo " [<b>$x</b>] ";
      // if not current page...
      } else {
         // make it a link
         echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$x'>$x</a> ";
      } // end else
   } // end if 
} // end for
                 
// if not on last page, show forward and last page links        
if ($currentpage != $totalpages) {
   // get next page
   $nextpage = $currentpage + 1;
    // echo forward link for next page 
   echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$nextpage'>></a> ";
   // echo forward link for lastpage
   echo " <a href='{$_SERVER['PHP_SELF']}?currentpage=$totalpages'>>></a> ";
} // end if
/****** end build pagination links ******/

echo "</div>";
echo "</div>";
echo "</div>";


// include the page footer
include('includes/template/footer.php');
mysql_close($con);
?>

Recommended Answers

All 3 Replies

suggestion?

Are you getting any errors from PHP or mysql_errors?

Have you tried turning on the PHP error reporting with:

<?PHP
ini_set('error_reporting',E_ALL);
ini_set('display_errors','On'); 
?>

well I was not getting any errors, but someone did give me a link to a youtube video that walked me through a pagination tutorials and I was able to get a simple pagination setup on my site. Unfortunately it is not as advanced as this one, but it will work!

Thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.