Jump to content

New pages


Andy11548

Recommended Posts

The code in that tutorial is what you'll need to use in order to make page links. There is no built-in function that will do this for you. The code is actually very simple. You will only need to modify a cople of lines of code to make it work with your code.

 

The first bit of code you need to modify is this part

// find out how many rows are in the table 
$sql = "SELECT COUNT(*) FROM numbers";
$result = mysql_query($sql, $conn) or trigger_error("SQL", E_USER_ERROR);
$r = mysql_fetch_row($result);
$numrows = $r[0];

You will only need to edit the sql query ($sql = "SELECT COUNT(*) FROM numbers";) so it returns the number of threads in the current forum.

 

The next bit you edit

// get the info from the db 
$sql = "SELECT id, number FROM numbers LIMIT $offset, $rowsperpage";
$result = mysql_query($sql, $conn) or trigger_error("SQL", E_USER_ERROR);

// while there are rows to be fetched...
while ($list = mysql_fetch_assoc($result)) {
   // echo data
   echo $list['id'] . " : " . $list['number'] . "<br />";
} // end while

In the above block you can just replace the query ($sql) which your current query for getting the threads.  Just add LIMIT $offset, $rowsperpage to the end of your query And finally replace the while loop which your loop for displaying the threads.

 

Link to comment
https://forums.phpfreaks.com/topic/241497-new-pages/#findComment-1240521
Share on other sites

I was about to ask the dumbest question ever.

 

"What is the 'numbers' part all about in the SQL?"

 

it confused me for about 10 minuets then it struck me and I started laughing at my stupidity lmao.

 

I will crack on and see how it goes.

 

Thanks for your help, I really appriciate it.

 

Thanks again,

Andy.

Link to comment
https://forums.phpfreaks.com/topic/241497-new-pages/#findComment-1240527
Share on other sites

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.