mike12255 Posted March 3, 2009 Share Posted March 3, 2009 So im trying to create it so i query my db and get all the questions inserted into it, and it displays them from newest to oldest. Then, I want to make it so that it shows four per page. So it will show four questions there status (answered or not) and then underneither numbers: 1 2 3 4 ect depending on how many pages to show. My problem now lies inbetween the query and putting down the required amount of pages. I dont know how to use my query to displaye the x-x amount on the page (1-4,5-8 ect) the buttons will link to www.stayner.ca/index.php?page=X were 1 = questions 1-4. Below is my current code: <?php $tolimit = 4; //Get all Topics (Parentid = 0) $getthreads="SELECT * from forumtutorial_posts WHERE parentid='0' order by parentid DESC"; //grab all the content while($r=mysql_fetch_array($getthreads)) { //the format is $variable = $r["nameofmysqlcolumn"]; - makes it easier to call later CAUSE IM LAZY!! $answer=$r["answer"]; $title=$r["title"]; } $findamount = mysql_query($postquery) or die (mysql_error()); $num_rows = mysql_num_rows($findamount); $pagestoshow = floor($num_rows/$tolimit); for ($i = 1; $i <= $pagestoshow; $i++){ print "<a href= 'answer.php?id=$id$page=$i&catagory=$area> $i </a>"; } ?> Link to comment https://forums.phpfreaks.com/topic/147690-solved-showing-x-amount-of-titles-from-mysql-on-a-page/ Share on other sites More sharing options...
genericnumber1 Posted March 3, 2009 Share Posted March 3, 2009 Google "php pagination" Link to comment https://forums.phpfreaks.com/topic/147690-solved-showing-x-amount-of-titles-from-mysql-on-a-page/#findComment-775236 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.