Jump to content

Recommended Posts

Well mabey my title exagerates a little much, but in the end im not getting the proper numbers. Im trying to paginate or whatever its called with four topics on a page. I have done this before and i know my only problem is getting the number of topics from my database, can somone figure out were i messed up?:

 

 <?php  if(isset($_GET['id'])) {
  $page = $_GET['id'];
}else{
  $page = 1;
}
  $tolimit = 4;
  $showend = $page * $tolimit;
  $showstart =  $showend - 4;
  //Get all Topics (Parentid = 0)
$getthreads="SELECT * FROM forumtutorial_posts WHERE parentid ='0' ORDER BY parentid DESC LIMIT $showstart, $tolimit";
$findamount = mysql_query($getthreads) or die (mysql_error());
$num_rows = mysql_num_rows($findamount);
print sizeof($num_rows);
$pagestoshow = floor($tolimit/$num_rows);
//grab all the content
while($r=mysql_fetch_array($findamount))
{   
//the format is $variable = $r["nameofmysqlcolumn"]; - makes it easier to call later CAUSE IM LAZY!!
$answer=$r["answered"];
$title=$r["title"];
$id=$r["postid"];

if ($answer == 0){
$answer = "no";
}else{
$answer = "yes";
}

?>

<td bgcolor="#FFFFFF"><div align="left" class="style17"><a href="showquestion.php?page=<?=$id?>"><?=$title?></a></div></td>
<td bgcolor="#FFFFFF"><div align="center" class="style17"><?=$answer?></div></td> </tr>
   
     <?php
}
print "<td>Page: </td>";


for ($i = 1; $i <= $pagestoshow; $i++){
print "<td><a href= 'index.php?page=$i'> $i </a></td>";

 

 

P.S idk what these #160 things are they just appeared on their own.

Link to comment
https://forums.phpfreaks.com/topic/148186-my-query-lies/
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.