...

View Full Version : Doing functions based on result



WebmasterLULZ
12-07-2008, 12:10 PM
How would i go about doing


SELECT firstname FROM users WHERE username = '$_SESSION[username]'

and if mysql result (from doing the above selection) is "jake" do this function , else this function.

guelphdad
12-07-2008, 04:19 PM
you would handle that in your front end application code.

WebmasterLULZ
12-08-2008, 12:27 AM
yea. I am doing it in PHP, and i want to know how i would go about doing it in PHP.

SELECT firstname FROM users WHERE username = '$_SESSION[username]'

I want to get the result from that.. so if the result is bob , do this function , else do another function

194673
12-08-2008, 01:29 AM
$sql = "SELECT firstname FROM users WHERE username = '$_SESSION[username]'";
$result = mysql_query($sql);
$row = mysql_fetch_array($result);
if ($row['firstname'] == 'bob')
{
someFunction();
} else {
anotherFunction();
}



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum