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