Not getting the full value in $_GET[] variable

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
webspider
Forum Commoner
Posts: 52
Joined: Sat Oct 27, 2007 3:29 am

Not getting the full value in $_GET[] variable

Post 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?
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

Put all attribute values in quotes, just like you did with selected="selected"
<option value=xyz> <- no no
<option value="xyz"> <- yes
User avatar
CoderGoblin
DevNet Resident
Posts: 1425
Joined: Tue Mar 16, 2004 10:03 am
Location: Aachen, Germany

Post by CoderGoblin »

Use

Code: Select all

echo "<option value=\"$value\" selected=\"selected\">".$value."</option>";
. The $value must be quoted.
User avatar
webspider
Forum Commoner
Posts: 52
Joined: Sat Oct 27, 2007 3:29 am

Post by webspider »

Thank you both for your help..........
Post Reply