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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.