Ignoring spaces from checkbox input
Posted: Wed Feb 28, 2007 10:42 am
Hi, I have a form that gets its checkbox values from a table called 'destination'. The form also gathers user information and puts it in another table called 'customer'. When it comes to selecting the checkbox values and submitting, the code works as it takes the customer's userid and the destination id from the checkbox values and putting them in a new table called 'custdest' EXCEPT if the destination has a space in it's name, e.g "New York". It completely ignores this value and moves on to the next.
Here's the code for the form
and here's the code for the processing
anyone's help will be much appreciated!
Here's the code for the form
Code: Select all
mysql_select_db("system", $con);
$result = mysql_query("SELECT * FROM destination");
while($row = mysql_fetch_array($result))
{
echo $row['destname'];
echo "<input type=\"checkbox\" name=\"" . $row['destname'] . "\" value=\"" . $row['destid'] . "\">";
echo "<br />";
}
mysql_close($con);
?>Code: Select all
while($row = mysql_fetch_array($result))
{
$currentdbdest = $row['destname'];
$currentpostdest = $_POST[$currentdbdest] + "";
echo $currentpostdest;
if ($currentpostdest != null){
echo $row['destname'];
mysql_query("INSERT INTO custdest (userid, destid) VALUES ('$userid', '$row[destid]')");
}
}