Jump to content

page links not working


justAnoob

Recommended Posts

Ok, I found an example online, and gave it a little tweak(not much) so I can get the idea of how pagination page numbers work. My page displays with the corrent amount of rows from the database that I want on a page. Here is the prob. When I click on a page number, the same entries are shown. Can anyone throw me a pointer.

<?php 
include 'connection.php';
$cat = "DVDs";
$query = "SELECT id FROM my_table WHERE category = '$cat' ";
$result = mysql_query($query);
$count =  mysql_num_rows($result);

$display = 2; 

if (empty($startrow))
{ 
    $startrow=0; 
} 

$query2 = "SELECT thumb_1 FROM my_table WHERE category = 'DVDs' LIMIT $startrow, $display"; 
$result2 = mysql_query($query2); 

echo "<table border='0' CELLPADDING=5 STYLE='font-size:16px'>";
while ($row = mysql_fetch_array($result2))
{ 
       echo "<tr><td align='center'>";
   echo '<a href="viewmovie.php?sendto='.$row['id'].'"><img src="' . $row['thumb_1'] . '" width="90" border="0" alt=""></a></td></tr>';
   echo '<tr><td>';
       echo '<hr width="550">';
       echo "</td></tr>";    
}
echo "</table>";

if ($startrow > 1)
{ 
    $prevrow = $startrow - $display; 
    echo '<a href="testing2.php?startrow=$prevrow">Previous</a> ';
}

$pages = intval($count / $display); 

if ($count % $display)
{ 
    $pages++; 
} 

if ($pages > 1)
{ 
    for ($i=1; $i <= $pages; $i++)
{ 
    	$next = $display * ($i - 1); 
    	echo '<a href="testing2.php?startrow=$next">$i</a> ';
}

} 

if (!(($startrow / $display) == $pages) && $pages != 1)
{ 
    $next = $startrow + $display; 
    echo '<a href="testing2.php?startrow=$next">Next</a> '; 
} 

if ($count < 1) { 
    echo "Nothing, sorry. Please try again.";
} 
?>

Link to comment
https://forums.phpfreaks.com/topic/186654-page-links-not-working/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.