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

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.