Jump to content

Need a little help passing a variable


sptrsn

Recommended Posts

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

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.

Archived

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

×
×
  • 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.