Jump to content

Php to read mysql table


travelkind

Recommended Posts

I need my php script to read a mysql table "rawdata" and return a field in it if the following criteria is met:

 

'supplier' field is equal to "SU" and

'terminal' field is equal to "GT" and

'product' field is equal to "UL LS DIESEL" and

'bub' field is equal to to "B"

If all this criteria is met than return from the "rawdata" table the 'price' field.  If all the conditions are not met than return "0.00"

 

Any input would be greatly appreciated.

Link to comment
https://forums.phpfreaks.com/topic/187466-php-to-read-mysql-table/
Share on other sites

Any input would be greatly appreciated.

 

I'd recommend making an attempt for yourself.  You're fortunate SA has given you an example.

 

You can lookup syntax and definitions here: http://www.mysql.com/

 

We don't mind helping, but we don't like giving you direct answers, to what seems to be, a HW assignment.

Okay this is the code I used:

 

mysql_query("SELECT `price` FROM `rawdata` WHERE `supplier`='SU' AND `terminal`='GT' AND `product`='UL LS DIESEL' AND `bub`='B'");

echo $row['price'];

 

It returned data from the `price` field but it just grabbed the first entry in the table and didn't specifically follow the conditions I outlined.  Where did I go wrong?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.