Jump to content

query problem.


Scip

Recommended Posts

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

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.