How would I add a variable that I will assign to a list of $_POST
variables that I extract from a form?
My form passes a value for $q. That works fine. What I want to do is run
an if/else on it and assign a new variable based on what was chosen such as
if ($q == "red") {
$q = "tp"; //change $q to this value
$sub = "ak"; //attach this value to the $sub variable
} else {
$q = $q; //don't change the value of $q
$sub = ""; //Leave $sub empty
}
Then both the $q and $sub will get added to a mysql_query for insertion.
mysql_query("IN SERT INTO `table` VALUES(\"\",\"$ q\",\"$sub\",\" $comments
- $name\",\"$emai l\",\"$today\", \"\" )") or die(mysql_error ());
I can get it to add the $q with no problem but it isn't recognizing the
$sub that wasn't part of the original $_POST variables. Any suggestions?
variables that I extract from a form?
My form passes a value for $q. That works fine. What I want to do is run
an if/else on it and assign a new variable based on what was chosen such as
if ($q == "red") {
$q = "tp"; //change $q to this value
$sub = "ak"; //attach this value to the $sub variable
} else {
$q = $q; //don't change the value of $q
$sub = ""; //Leave $sub empty
}
Then both the $q and $sub will get added to a mysql_query for insertion.
mysql_query("IN SERT INTO `table` VALUES(\"\",\"$ q\",\"$sub\",\" $comments
- $name\",\"$emai l\",\"$today\", \"\" )") or die(mysql_error ());
I can get it to add the $q with no problem but it isn't recognizing the
$sub that wasn't part of the original $_POST variables. Any suggestions?
Comment