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