"if" problem
Posted: Fri Dec 17, 2004 4:27 pm
I'm new to PHP/SQL and have a simple problem - I've looked around various sites about if statements and I can't find the problem.
This bit of code is ignoring the if statements, it writes the variable $new_driver to all three fields when it should only do it on one field depending on what $new_drivers is set to.
Any ideas?
I know the code is not very elegant but I'm learning!
This bit of code is ignoring the if statements, it writes the variable $new_driver to all three fields when it should only do it on one field depending on what $new_drivers is set to.
Code: Select all
if ($new_drivers=1) {
$query = ("UPDATE teams SET driver_one='$new_driver_id' WHERE id='$ids'";)
mysql_query($query) or die (mysql_error());
}
if ($new_drivers=2) {
$query = ("UPDATE teams SET driver_two='$new_driver_id' WHERE id='$ids'");
mysql_query($query) or die (mysql_error());
}
if ($new_drivers=3) {
$query = ("UPDATE teams SET test_driver='$new_driver_id' WHERE id='$ids'");
mysql_query($query) or die (mysql_error());
}I know the code is not very elegant but I'm learning!