mike12255 Posted March 6, 2009 Share Posted March 6, 2009 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 More sharing options...
RussellReal Posted March 6, 2009 Share Posted March 6, 2009 try this query mysql_query("SELECT * FROM `forumtutorial_posts` WHERE `parentid` = '0' LIMIT ".(($page - 1) * $tolimit).",4"); Link to comment https://forums.phpfreaks.com/topic/148186-my-query-lies/#findComment-777983 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.