Page 1 of 1

pagination trouble

Posted: Sat Apr 09, 2011 1:23 pm
by simmsy
Hey everyone im having a little trouble with my forum pagination on the replies. I am using the the id of the topic as the page so this is what it looks like for the link:
" echo " <tr><td height='50' align='center' valign='top' bgcolor='#AAAAAA'><b>$username</b><br />$date<br />$time</td>
<td height='50' align='center' bgcolor='#AAAAAA'><b><a href='viewtopic.php?id=$id'>$topic</a></b></td></tr>";"
so the link is http://...........viewtopic.php?id=1
I am using this pagination

***** PLEASE USE PHP CODE TAG *****

Code: Select all

<?
//display data
$get = mysql_query("SELECT * FROM reply WHERE reply_id='$id' LIMIT $start, $per_page");
while ($row = mysql_fetch_assoc($get))
  {
   //get data
   $a_username = $row['a_username'];
   $a_date = $row['a_date'];
   $a_time = $row['a_time'];
   $a_reply = $row['a_reply'];
   
   echo "  <tr><td height='50' align='center' valign='top' bgcolor='#AAAAAA'><b>$a_username</b><br />$a_date<br />$a_time</td>
  <td height='50' align='center' bgcolor='#AAAAAA'>$a_reply</td></tr>";
   
  }

  ?>

  </table>
  <p />
 
  <div align='center'>
  <?
//setup prev and next variables
$prev = $start - $per_page;
$next = $start + $per_page;

//show prev button
if (!($start<=0))
      echo "<a href='viewtopic.php?start=$prev'>Prev</a> ";
      
//show page numbers

//set variable for first page
$i=1;

for ($x=0;$x<$record_count;$x=$x+$per_page)
{
   if ($start!=$x)
      echo "<a href='viewtopic.php?start=$x'>$i</a> ";
   else
      echo "<a href='viewtopic.php?start=$x'><b>$i</b></a> ";
$i++;
}

//show next button
if (!($start>=$record_count - $per_page))
      echo " <a href='viewtopic.php?start=$next'>Next</a>";

?>
but then when I click on the next page or one of those links it comes out like this http://...........viewtopic.php?id=1?start=2
then click it again http://...........viewtopic.php?id=1?start=2?start=2 and adds that every time I click it
can anyone help its the last part of making my forum, please?