RE: [PHP-DB] If else trouble
| From: | Peter Lovatt | Date: | Sun, 24 Feb 2002 23:19:12 +0000 |
| Subject: | RE: [PHP-DB] If else trouble | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-17245@lists.php.net to get a copy of this message | ||
Hi
> -----Original Message-----
> From: Jennifer Downey [mailto:jendowney@attbi.com]
> Sent: 24 February 2002 22:28
> To: php-db@lists.php.net
> Subject: [PHP-DB] If else trouble
>
>
> Hi all,
>
> I have worked and re-worked this if else statement. I can't get
> it to work.
>
> It's suppose to work like this.
>
> If there are no points in the bank then echo but it always echo's
> you don't
> have enough points. It also wont keep me from withdrawing more than I have
> in the bank.
>
> What am I doing wrong and how do I keep the script from letting
> me withdraw
> more than I have, and keep it from echoing "you don't have enough points!"
> all the time?
>
> $sql_result = mysql_query("SELECT * FROM bank_points WHERE
> uid={$session["uid"]}");
> if ($sql_result <= "0") {
> echo "you don't have enough points!";
>
> }else{
> echo "Your withdraw has been made!";
> }
>
$sql_result is the result ID,
you need
$row = mysql_fetch_array($sql_result)
which loads the returned row into an array $row
Guessing your field is called bank_points_total
if ($row["bank_points_total"] <= "0")
{
echo "you don't have enough points!";
}
else
{
echo "Your withdraw has been made!";}
}
HTH
Peter
-----------------------------------------------
Excellence in internet and open source software
-----------------------------------------------
Sunmaia
www.sunmaia.net
info@sunmaia.net
tel. 0121-242-1473
-----------------------------------------------
> Thanks in advance
> Jennifer Downey
>
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>