sptrsn Posted March 17, 2011 Share Posted March 17, 2011 I'm an hour worth of searches into this. It's 2:30. I just want some nice person to give me the answer. I'm trying to pass a variable using href to another page. It works great if the variable is only one word. But it only passes the first word. There are multiple posts on this topic, but I can't seem to get any of those fixes to work for me. Here the code. <?php $query = "select DISTINCT city from daily where open_bid>0 order by city ASC"; $result = mysql_query($query); while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $details=''; $details.='<li class="menu"><span class="name"><a href=list.php?city='.$row['city'].'>'.$row['city'].'</a>'; $details.='</li>'; echo($details); } ?> As you can imagine, some cities names are made up of two words. This is only passing the first word. Thanks for your help. Link to comment https://forums.phpfreaks.com/topic/230902-need-a-little-help-passing-a-variable/ Share on other sites More sharing options...
litebearer Posted March 17, 2011 Share Posted March 17, 2011 http://php.net/manual/en/function.urlencode.php Link to comment https://forums.phpfreaks.com/topic/230902-need-a-little-help-passing-a-variable/#findComment-1188593 Share on other sites More sharing options...
sptrsn Posted March 17, 2011 Author Share Posted March 17, 2011 thank you. That and a little sleep does wonders. urlencode worked. Here's where I changed... <?php $query = "select DISTINCT city from daily where open_bid>0 order by city ASC"; $result = mysql_query($query); while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $details=''; $details.='<li class="menu"><span class="name"><a href=list.php?city='.(urlencode($row['city'])).'>'.$row['city'].'</a>'; $details.='</li>'; echo($details); } ?> Thanks again. Link to comment https://forums.phpfreaks.com/topic/230902-need-a-little-help-passing-a-variable/#findComment-1188656 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.