Jump to content

Recommended Posts

The urls on my localhost look like a joke and I hope someone has a solution.

 

I use $_SERVER['QUERY_STRING'] so the first number looks okay, it's that as I go up in page number to 2,3,4,5, etc it starts to look funky.

 

The first time before the 2 for the second page is clicked it looks normal, the second time after the 2 is clicked they look screwy and as you can guess it keeps getting longer each time a number is clicked.

 

I know that each time I go to a new page $_SERVER['QUERY_STRING'] changes and thats the problem.

 

Here is the code I use

$qstring= htmlentities($_SERVER['QUERY_STRING']);
// Make links to other pages
	if (($pages > 1) && ($start >= 0)) {

		// Add space and start a paragraph
		echo "\n<div id=\"page_num\"><p>";

		// Determine what page the script is on
		$current_page = ($start/$display)+1;

		//If its not the first page make a previous button
		if ($current_page !=1) {
			echo '<a href="subject.php?'.$qstring.'&s=' . ($start-$display) . '&p=' . $pages . '">Previous</a> ';
		}

		//Make all the numbered pages
		for ($i = 1; $i <=$pages; $i++) {
			if ($i !=$current_page) {
		echo '<a href="subject.php?'.$qstring.'&s=' . (($display * ($i - 1))) . '&p=' . $pages . '">' . $i . '</a>';
		} else {
		echo $i . '';
		}
		} //End for loop

		// If its not the last page make a next button
		if ($current_page != $pages) {
			// $qstring = str_replace("($start + $display)&p=$pages", "", $qstring);
			echo '<a href="subject.php?'.$qstring.'&s=' . ($start + $display) . '&p=' . $pages. '">Next</a>';
			}
			echo "</p>\n</div><!-- End page numbers div -->\n"; // Close paragraph

		} // End of "if (($pages > 1) && ($start >= 0))" links 

 

Is there a work around to this, a different way of doing it and if or switch or  something.

thanks

Thanks PFMaBiSmAd, I'll check that now.

 

I was just getting ready to post this

---------------------------------------------------------------------------------------------------------------------------------------------------

Okay what I've done was I put use my if conditions for the sql and hard coded it like this

 

     if ((!$id_sub) && ($state)) {
// Select records to display
$q = "SELECT ................................... ";

$qstring = "cat=$category&id_sub=Null&state=$state;
}

              if ((!$id_sub) && (!$state)) {
// This is the ********** MAIN QUERY **********
// Select records to display
$q = "SELECT ................................... ";

$qstring = "cat=$category";
}

Then I insert it into echo '<a href="subject.php?'.$qstring.'&s=' . ($start-$display) . '&p=' . $pages . '">Previous</a> ';

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.