I have a drop down list that selects the table to insert data into I have the if commands set but how do I make it work
Shouldn't I have something of the dropdown name here:
$buyer = addslashes($_POST['buyer']);
$purchase_date = addslashes($_POST['purchase_date']);
$warranty = addslashes($_POST['warranty']);
$recieved_date = addslashes($_POST['recieved_date']);
$year = addslashes($_POST['year']);
$model = addslashes($_POST['model']);
$vin = addslashes($_POST['vin']);
$color = addslashes($_POST['color']);
Here is the if statements I have specified:
if($yamaha_cruiser)
{
$sql = "INSERT INTO `yamaha cruisers` (`buyer`,`purchase_date`,`warranty`,`recieved_date`,`year`,`model`,`vin`,`color`) VALUES ('".$buyer."','".$purchase_date."','".$warranty."','".$recieved_date."','".$year."','".$model."','".$vin."','".$color."')";
}
if($kawasaki cruiser)
{
$sql = "INSERT INTO `kawasaki cruisers` (`buyer`,`purchase_date`,`warranty`,`recieved_date`,`year`,`model`,`vin`,`color`) VALUES ('".$buyer."','".$purchase_date."','".$warranty."','".$recieved_date."','".$year."','".$model."','".$vin."','".$color."')";
}
//check that either choice1 or choice2 has been selected, then execute the sql
if($sql)
{
$result = mysql_query($sql);
}
{
echo "Unit added to database.";
exit;
}
?>
I have already tried the mysql manual with no luck.