Scip Posted June 29, 2009 Share Posted June 29, 2009 I have an array of key value pairs and i am trying to use a foreach loop to loop through the array performing a database query for each key and as such i only expected one value to be return but it returns the whole column. here is the code i am using: foreach($requests as $key => $value){ $query = "SELECT quantity FROM resource WHERE resource_name = '{$key}' "; $result_set = mysql_query($query,$connection); confirm_query($result_set); } a print_r after the result_set has been fectched to a variable shows the results for quantity for every row in the table 'resource' whilst it should only for the row with the resource_name of $key; any help it appreciated, thanks in advance. Link to comment https://forums.phpfreaks.com/topic/164122-query-problem/ Share on other sites More sharing options...
Scip Posted June 29, 2009 Author Share Posted June 29, 2009 managed to solve it but created another problem. :-X Link to comment https://forums.phpfreaks.com/topic/164122-query-problem/#findComment-865797 Share on other sites More sharing options...
JJ2K Posted June 29, 2009 Share Posted June 29, 2009 Well whats the new problem and how did you solve it Link to comment https://forums.phpfreaks.com/topic/164122-query-problem/#findComment-865799 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.