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

From: Date: Sat, 21 Jul 2001 21:46:25 +0000
Subject: RE: [PHP-DB] Wrong solution!!!!
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-10632@lists.php.net to get a copy of this message
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 "<b><font color=\"#FF0000\">Out of Stock $result</font></b>"; } else { echo "<b><font color=\"#0000FF\">In Stock $result</font></b>"; } ?> -----Original Message----- From: Tony [mailto:tony777@qwest.net] Sent: Saturday, July 21, 2001 2:32 PM To: php-db@lists.php.net 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, item inventory 15109 0 15110 12 14590 7 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 "<b><font color=\"#FF0000\">Out of Stock $result</font></b>"; } else { echo "<b><font color=\"#0000FF\">In Stock $result</font></b>"; } I want my inventory quantity with known item number to compare with ($num<1), 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: php-db-unsubscribe@lists.php.net For additional commands, e-mail: php-db-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.db (#10632) next »