Jump to content

Next button


everlifefree

Recommended Posts

ok i'm looking to make a next button for my site that goes up looks at the id of the page your on and then when you click the next button it takes you to the next one in line it the database. and it can't just go 1, 2, 3, 4, ect. because there are missing variable from deletions some it'd need to be able to read like this 1, 2, 5, 6, 7, 12, ect. (you get the point of just serveal missing numbers between.

Link to comment
Share on other sites

use SELECT * FROM TABLES WHERE id>=$id AND ... LIMIT 2

in 1st featch you have curent data, and in 2nd is next id

why dont you just do it this way  so it will only fetch one record?

SELECT * FROM TABLES WHERE id>$id AND ... LIMIT 1

Link to comment
Share on other sites

Here's the code I attempted but I get all it puts in {ezine.id2} is the number 1 and that isn't right! Can anyone tell me where I went wrong??

 

if (isset($_GET["id"])) 
	$row2 = myF(myQ("
		SELECT * 
		FROM `[x]gallery` 
		WHERE 'id' > '{$_GET["id"]}' 
		AND `processed` = '1'
		ORDER BY 'id' ASC
		LIMIT 1
	"));

$tpl -> AssignArray(array(
	"ezine.id2" => $row2["id"],
));

Link to comment
Share on other sites

I'm about to go on a trip with the wife so I only have about one minute to post. I dont know what is wrong with your current code, but use this:

 

if(isset($_GET['page_id']))
{
   $query = "SELECT page_id FROM pages WHERE page_id > " . $_GET['page_id'] . " ORDER BY page_id ASC LIMIT 1";
}
else
{
    $query = "SELECT page_id FROM pages WHERE page_id > 1 ORDER BY page_id ASC LIMIT 1";
}
// Do your mysql query here
echo "<a href=\"page_name?page_id=" . $page_id_taken_from_database . "\">NEXT PAGE</a>";

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.