Jump to content

[SOLVED] Showing X amount of titles (from mysql) on a page


mike12255

Recommended Posts

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>";
}   

 ?>

Archived

This topic is now archived and is closed to further replies.

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