pwesthead Posted July 25, 2015 Share Posted July 25, 2015 I have a dropdown list in a html form, i get the info for the dropdown list from mysql database using php, the problem is when i choose a name from the drop downlist and echo the name out i only get half the name if there is a gap in the name, eg if i get a name bart simpson it will only output bart and not show the last name, its something to do with the space in the name. here is the code. <form action='<?php echo $_SERVER['PHP_SELF']?>' method=post> <select name='charity_name' id="charity_name"> <option <?php //loop through categories table rows while ($row=mysql_fetch_array($charity)){ echo "<option value=$row[charity_name]>$row[charity_name]"; } ?></option> </select> <input type=submit value="Go"> </form> <? $charity_name=$_POST['charity_name']; ?> <?php echo $charity_name;?> thanks paul Quote Link to comment https://forums.phpfreaks.com/topic/297466-html-php-form-problem/ Share on other sites More sharing options...
Solution PravinS Posted July 25, 2015 Solution Share Posted July 25, 2015 (edited) use quotes around option value or use select box as <select name="charity_name" id="charity_name"> <?php while ($row=mysql_fetch_array($charity)) { echo '<option value="'.$row[charity_name].'">'.$row[charity_name].'</option>'; } ?> </select> hope this will help you Edited July 25, 2015 by PravinS Quote Link to comment https://forums.phpfreaks.com/topic/297466-html-php-form-problem/#findComment-1517341 Share on other sites More sharing options...
pwesthead Posted July 25, 2015 Author Share Posted July 25, 2015 Ha Ha so easy when you know how thanks paul Quote Link to comment https://forums.phpfreaks.com/topic/297466-html-php-form-problem/#findComment-1517342 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.