Jump to content


Photo

Pagination Problem? [solved]


  • Please log in to reply
3 replies to this topic

#1 hostfreak

hostfreak
  • Members
  • PipPipPip
  • Advanced Member
  • 581 posts

Posted 24 August 2006 - 09:34 AM

I have locations in a database. Here is an example of some of the locations:

Punta Gorda
Fort Myers

So I have my script setup to where you can view employee's by location. I have also added pagination to it. The way I link to the page are like:

employee.php?page=employee/plant_normal&location=Punta Gorda

If I were to go to that page, it would add "%20" between "Punta" and "Gorda". Thats fine, it works. However when I go to click any of the pages setup with the pagination, it takes off everything past the "Punta". It works just fine with locations that dont have spaces. So I am not sure what to do.

Here is a snippet of the pagination code that echo's the links for the pages:

<?php
$totalpages = mysql_num_rows(mysql_query("SELECT * FROM users WHERE userlevel='2' AND location='$location'"));
$totalpages = $totalpages / $limit;
$totalpages = $totalpages;
$c = 0;
echo "<br>";
while($c<$totalpages){
$page = $c + 1;
if($_GET['num']==$page){
echo "[$page] ";
}else{
echo "<a href=employee.php?page=employee/plant_normal&location=$location&num=$page><b>$page</b> </a>";
}
$c = $c+1;
}
echo "<br>".$totalpages." Pages in total.";
?>

Thanks in advance for any responses.




#2 Kris

Kris
  • Staff Alumni
  • Advanced Member
  • 2,755 posts
  • LocationThe Internet

Posted 24 August 2006 - 11:05 AM

Could you run your URL (or just the parameters) through the url_encode() function?

#3 hostfreak

hostfreak
  • Members
  • PipPipPip
  • Advanced Member
  • 581 posts

Posted 24 August 2006 - 11:21 AM

Hmm, not sure how to use that function. Went to the php.net site, here what I have come up with:

echo "<a href=employee.php".urlencode(?page=employee/plant_normal&location=$location&num=$page)."><b>$page</b> </a>";

If that is correct, then it didn't do anything for me.

#4 hostfreak

hostfreak
  • Members
  • PipPipPip
  • Advanced Member
  • 581 posts

Posted 24 August 2006 - 11:46 AM

Ah darn! I was uploading the file in the wrong place. I got it to work with what you suggested "urlencode()". Except not the code I posted above, instead:

echo "<a href=equipment.php?page=equipment/plant_normal&location=".urlencode($location)."&num=$page><b>$page</b> </a>";

And it worked. Thanks.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users