Jump to content

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?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.