RE: [PHP-DB] Wrong solution!!!!

2001-07-21 Thread David Balatero

I assume you want to do this instead..try it:

?php
$itemx = 15109;
$sql = SELECT quantity FROM inventory WHERE item = '$itemx';
$result = mysql_query($sql,$link);
$row = mysql_fetch_array($result); // you have to fetch the result into an
array to access the info in the db
$num = $row[quantity];

// NOW we can compare $num ;)
if ($num  1) {
echo bfont color=\#FF\Out of Stock $result/font/b;
} else {
echo bfont color=\#FF\In Stock $result/font/b;
}
?

-Original Message-
From: Tony [mailto:[EMAIL PROTECTED]]
Sent: Saturday, July 21, 2001 2:32 PM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] Wrong solution


Hello,
I really do appreciate your help.

But, I found out that the solution scrip that you gave me was wrong script
for my purpose.
I guess I didn't describe my problem right.
I didn't mean to get the total number of rows to compare.

Let's say I have a table name inventory and contains two columes.
Here is example,

iteminventory
   15109 0
1511012
145907
This is a script that I tried and didn't work.

$itemx = 15109;
  $num = mysql_query(SELECT quantity FROM inventory WHERE item =
'$itemx',$link);
  if ($num  1) {
  echo bfont color=\#FF\Out of Stock $result/font/b;
  } else {
  echo bfont color=\#FF\In Stock $result/font/b;
  }

I want my inventory quantity with known item number to compare with
($num1), but didn't work.
Can you tell me how about solving this problem?
Thanks for your time again.
Tony



--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] Wrong solution!!!!

2001-07-21 Thread Julie Meloni

T $itemx = 15109;
T   $num = mysql_query(SELECT quantity FROM inventory WHERE item =
T '$itemx',$link);
T   if ($num  1) {
T   echo bfont color=\#FF\Out of Stock $result/font/b;
T   } else {
T   echo bfont color=\#FF\In Stock $result/font/b;
T   }

T I want my inventory quantity with known item number to compare with
T ($num1), but didn't work.


You have not yet gotten the result of the query.  Use mysql_result()
or any of the result-related functions to get the actual result of the
query.

All you're doing now is executing the query, which, if you've
connected successfully and there's nothing wrong with your sql, will
return true.


   Julie Meloni 
[EMAIL PROTECTED]
PHP Essentials  PHP Fast  Easy
 --- www.thickbook.com ---


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]