Page 1 of 1

Not getting the full value in $_GET[] variable

Posted: Tue Nov 27, 2007 9:19 am
by webspider
Hi there,
I used value from database which contain space.But I can not send this value by GET method.When I retrieve the value of $_GET[' '] ,only get the value before space. If the value is 'IP Phone', i am getting only 'IP'.Here is my code:

Code: Select all

<select name="category">

<?php
    new DbConnector();
    $selectname = 'select distinct name from product'; 
    $result = mysql_query($selectname);
                                      
     while($line = mysql_fetch_row($result))
     {
         foreach($line as $value)
        {
             if($value=='IP Phone') 
             echo "<option value=$value selected=\"selected\">".$value."</option>";		
             else
        	echo "<option value=$value>".$value."</option>";
         }
     }
 ?>

 </select>
I do not get the value after space by $_GET['category']. How can I get the full value?Any help?

Posted: Tue Nov 27, 2007 9:32 am
by volka
Put all attribute values in quotes, just like you did with selected="selected"
<option value=xyz> <- no no
<option value="xyz"> <- yes

Posted: Tue Nov 27, 2007 9:35 am
by CoderGoblin
Use

Code: Select all

echo "<option value=\"$value\" selected=\"selected\">".$value."</option>";
. The $value must be quoted.

Posted: Wed Nov 28, 2007 1:30 am
by webspider
Thank you both for your help..........