Jump to content

Pagination Problem? [solved]


hostfreak

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.


Link to comment
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.
Link to comment
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.
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.