Page 1 of 1

Problem with either a query or IF Statement

Posted: Mon Jun 02, 2008 7:47 am
by Cooperman
Can someone show me how I would write the IF Statement for:

I want the script to be able to go to the DB and see what access level is set.
1 should go to guest
2 should go to members

I'm not sure if it's my query at fault or the IF statement but every time it seems to be going to guest even if I have a "2" in my access row on the DB.

Please help. :cry:


$sql = 'SELECT * FROM `login`';
$result = mysql_query($sql);


if ($result ['access'] > 1) {
echo ("members only");

} else {

echo ("guest only");
}

Re: Problem with either a query or IF Statement

Posted: Mon Jun 02, 2008 8:00 am
by VladSun

Re: Problem with either a query or IF Statement

Posted: Mon Jun 02, 2008 8:03 am
by Cooperman
Thanks,

So how would I write that in the code? Sorry, I am a real Newbie to this...

Re: Problem with either a query or IF Statement

Posted: Mon Jun 02, 2008 8:11 am
by VladSun
There is a very good example in the manual I've pointed to. ;)

Re: Problem with either a query or IF Statement

Posted: Mon Jun 02, 2008 8:12 am
by Cooperman
Is this also the right way to query the DB for the row ACCESS?

if ($result ['access'] > 1) {

Re: Problem with either a query or IF Statement

Posted: Mon Jun 02, 2008 8:14 am
by VladSun
Please, read-the-manual ... All of your questions have their answers there.

Re: Problem with either a query or IF Statement

Posted: Mon Jun 02, 2008 8:23 am
by Cooperman
Thanks :)