hostfreak Posted August 24, 2006 Share Posted August 24, 2006 I have locations in a database. Here is an example of some of the locations:Punta GordaFort MyersSo 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. Quote Link to comment Share on other sites More sharing options...
zq29 Posted August 24, 2006 Share Posted August 24, 2006 Could you run your URL (or just the parameters) through the url_encode() function? Quote Link to comment Share on other sites More sharing options...
hostfreak Posted August 24, 2006 Author Share Posted August 24, 2006 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. Quote Link to comment Share on other sites More sharing options...
hostfreak Posted August 24, 2006 Author Share Posted August 24, 2006 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.