superblunt Posted June 24, 2008 Share Posted June 24, 2008 I am using php to get a few rows from mysql <?php $con = mysql_connect("localhost","root","****"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("aea", $con); $result = mysql_query('SELECT * FROM stock'); while($row = mysql_fetch_array($result)) { print_r($row); } ?> I get this Array ( [0] => 11 [stock_id] => 11 [1] => 2008-06-24 17:09:41 [date] => 2008-06-24 17:09:41 [2] => The Somerset Hotel [supplier] => The Somerset Hotel [3] => a1 [grade] => a1 [4] => sheep [mainitem] => sheep [5] => a213 [itemcode] => a213 [6] => 100.10 [itemmase] => 100.10 [7] => 10 [itemamount] => 10 [8] => Male [gender] => Male [9] => 900.40 [price] => 900.40 ) Array ( [0] => 10 [stock_id] => 10 [1] => 2008-06-24 16:48:53 [date] => 2008-06-24 16:48:53 [2] => The Somerset Compute [supplier] => The Somerset Compute [3] => a0 [grade] => a0 [4] => cow [mainitem] => cow [5] => a345 [itemcode] => a345 [6] => 100.12 [itemmase] => 100.12 [7] => 12 [itemamount] => 12 [8] => Female [gender] => Female [9] => 9876.23 [price] => 9876.23 ) I want to use the while function to get all the rows as seen above but i would like to specify the supplier name so it only show the array for a chosen supplier including all the amounts and prices thx Link to comment https://forums.phpfreaks.com/topic/111673-hi-i-am-a-noob-please-help/ Share on other sites More sharing options...
trq Posted June 24, 2008 Share Posted June 24, 2008 You'll want to do this in yor query. eg; SELECT * FROM stock WHERE supplier = 'foo'; Link to comment https://forums.phpfreaks.com/topic/111673-hi-i-am-a-noob-please-help/#findComment-573213 Share on other sites More sharing options...
superblunt Posted June 24, 2008 Author Share Posted June 24, 2008 thx allot Link to comment https://forums.phpfreaks.com/topic/111673-hi-i-am-a-noob-please-help/#findComment-573215 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.