Jump to content

adding the results of a query to another array for filtering


adambedford

Recommended Posts

I've got this query:

 

mysql_select_db($database_links, $links);
$businesses = mysql_query($query_businesses, $links) or die(mysql_error());
$row_businesses = mysql_fetch_assoc($businesses);
$totalRows_businesses = mysql_num_rows($businesses);

 

which returns a number of records (the query string is specified earlier in the code)... and it works perfectly (as it should!) but I want to add all the results of the query to another array so that I can filter them based on a value in the mysql table.

 

I know I can do this with another, more specific, MySQL query, but I thought this way would be more efficient (correct me if I'm wrong)

 

So i used this foreach loop to add the results to the associative array $featured_array

 

foreach ($row_businesses as $col => $val) {
  $featured_array = array($col => $val);
}

 

...except that it doesnt work! I wrote it myself and I'm new to this so that's probably why its not working but I'd appreciate a pointed in the right direction!

 

Also, am I going about this correctly? Should i simply use another query? Or is there a third, better way to achieving what I need.

 

Thanks in advance!

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.