Reply
Please help! I'm rubbish with IF statements
Old 05-27-2008, 11:31 AM Please help! I'm rubbish with IF statements
drew22299's Avatar
Skilled Talker

Posts: 89
Location: Wiltshire, UK
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";

__________________
www.hotlista.co.uk

Last edited by drew22299 : 05-27-2008 at 11:32 AM.
drew22299 is offline
Reply With Quote
View Public Profile Visit drew22299's homepage!
 
When You Register, These Ads Go Away!
Old 05-27-2008, 12:01 PM Re: Please help! I'm rubbish with IF statements
PeachyJuice's Avatar
Skilled Talker

Latest Blog Post:
One Month Progress Report
Posts: 94
Name: Michele T.
Location: Ny, Ny
You need to make VehicleID a variable in the query. Otherwise it's looking for the vehicle id 'VehicleID'
PHP Code:
$row=mysql_fetch_object(mysql_query("select * from Vehicles where Vehicleid='$VehicleID' and Userid='$Userid'")); 
That's your problem.
PeachyJuice is offline
Reply With Quote
View Public Profile
 
Old 05-27-2008, 12:08 PM Re: Please help! I'm rubbish with IF statements
drew22299's Avatar
Skilled Talker

Posts: 89
Location: Wiltshire, UK
Thanks!
__________________
www.hotlista.co.uk
drew22299 is offline
Reply With Quote
View Public Profile Visit drew22299's homepage!
 
Reply     « Reply to Please help! I'm rubbish with IF statements
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.11833 seconds with 12 queries