Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

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: 93
Trades: 0
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..
drew22299 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 05-27-2008, 12:01 PM Re: Please help! I'm rubbish with IF statements
PeachyJuice's Avatar
Super Talker

Posts: 116
Name: Michele T.
Location: Ny, Ny
Trades: 1
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: 93
Trades: 0
Thanks!
drew22299 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Please help! I'm rubbish with IF statements
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB 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.11424 seconds with 12 queries