Jump to content

html php form problem


pwesthead
Go to solution Solved by PravinS,

Recommended Posts

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

Link to comment
Share on other sites

  • Solution

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