Jump to content

Archived

This topic is now archived and is closed to further replies.

hostfreak

Pagination Problem? [solved]

Recommended Posts

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:

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

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:

[code]
<?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.";
?>
[/code]

Thanks in advance for any responses.


Share this post


Link to post
Share on other sites
Could you run your URL (or just the parameters) through the url_encode() function?

Share this post


Link to post
Share on other sites
Hmm, not sure how to use that function. Went to the php.net site, here what I have come up with:

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

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

Share this post


Link to post
Share on other sites
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:

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

And it worked. Thanks.

Share this post


Link to post
Share on other sites

×

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.