Hi,
I don't get why this IF statement won't work, I have tried putting the logic in different ways but still can't get it to work in the way I want it to work. Can anyone see why?
When the user clicks on the sell vehicle link, I want the php code to check if the Status of the vehicle is forsale, if it is already for sale tell user and don't update the vehicle status to forsale, if the status is not for sale update the Status column to forsale.
PHP Code:
$VehicleID=$_GET['vehicleid']; $Userid=$_SESSION['userid']; $row=mysql_fetch_object(mysql_query("select * from Vehicles where Vehicleid='VehicleID' and Userid='$Userid'")); $forsale=$row['Status']; IF($forsale == "forsale"){ echo "Vehicle is already listed in marketplace"; } else { $query2=mysql_query("update Vehicles set Status='forsale', Income='0', TotalIncome='0' where Userid='$_SESSION[userid]' AND Vehicleid ='$_GET[vehicleid]'"); $query = "SELECT * FROM Vehicles WHERE Userid='$_SESSION[userid]' AND Vehicleid ='$_GET[vehicleid]'"; $result = mysql_query($query) or die(mysql_error()); echo "Vehicle is now listed in the Marketplace"; }
Last edited by drew22299 : 05-27-2008 at 11:32 AM.
|