Jump to content

Recommended Posts

I already have this code but don't know how to make it so that it show's a next or previous link...

to set the varible's

if(isset($_GET['start'])){
$limit = $_GET['start'];
$endlimit = $_GET['start'] + 100;
}else {
$limit = 0;
$endlimit = 100;
}

the query

$sql = mysql_query("SELECT * FROM yourtable  ORDER BY id LIMIT {$limit},{$endlimit}") or die(mysql_error());

I can't understand the tutorial's very much so I tried a bit more and here are my results...

 

set the varible's

if(isset($_GET['start'])){
$limit = $_GET['start'];
$endlimit = $_GET['start'] + 100;
$morepages = $_GET['start'] + 100;
$lesspages = $_GET['start'] - 100;
}else {
$limit = 0;
$endlimit = 100;
$morepages = 200;
$lesspages = 0;
}

 

the query

$sql1 = mysql_query("SELECT * FROM youtable ORDER BY id LIMIT {$limit},{$endlimit}") or die(mysql_error());
$sql2 = mysql_query("SELECT * FROM youtable ORDER BY id") or die(mysql_error());

 

more pages and previous page links

if(mysql_num_rows($sql4) > $limit) {
echo "<p><a href='yourpage.php?start={$morepages}'>next page</a></p>";
}
if($limit > 100) {
echo "<p><a href='yourpage.php?start={$lesspages}'>previous page</a></p>";
}

 

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.