I am using PHP to query a mysql db.
After the query, I am using mysql_fetch_array in a while loop to display all results inside a table.
Now, depending on a variable ($adtypes) I want the query-results-array to change...
Explanation: ($query_results is the name of the array containing the query results,
basically something like SELECT * FROM table
so it selects everything!
$adtypes = $_GET['adtypes'];
//$adtypes is irrelevant to query, the query is already done before all this.
switch ($adtypes){
case "Private":
$query_results = //Here I want the array to only contain values where the mysql row field = 'Private'
break;
case "company":
$query_results = // Same thing as above, but only company ads
break;
}
Then I do a loop through the array to display the results like this:
while($row = mysql_fetch_array($query_results)){
How can I make sure the array (query_results) only contain the info I want WITHOUT doing another query ?
Thanks
If you need more input, tell me and I will update this Q.
UPDATE
I cannot have another query, because my queries are very large, and they DO affect performance in a negative way.
I Think a foreach is what I am after...
Also, the reason I cant manipulate the current query is because I am displaying the nr of private ads and nr of company ads on my site, and all that info comes from the query.
So, if I query my db where I only search for private ads, then I cant display how many company ads there where ( IF i dont do another query )!
Thanks anyways guys...