Hi guys, I used a while loop to put all mysql result sets into $all_products array. After that I used a foreach loop to grab all those dump for mysql_fetch_assoc to generate a table. I'm able to get the returns for print_r above as: however, PHP produces the following: PHP Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource Question:Is it because I stored the mysql dump into an array instead of using mysql_fetch_assoc to get the data, right after the execution of query thats causing the problem?
Yeah you're doing that a really funny way. You're making an array of an array and foreach'ing the print_r. Also the error means you have a problem with your query. Try something like this instead:
I agree with Goramba. You are doing it in a funny way. But you must have your reasons for doing it that way. About this error: You are getting thie error becuase you are passing '$all_products_set' to the mysql_fetch_assoc function. But becuase you did this on your first 'while' loop: while (something){ $temp_set = mysql_query($query); $all_products[] = Array("products" => $temp_set) } PHP: '$all_products_set' has been set as array and NOT the resource id. if you change $all_products[] = Array("products" => $temp_set) PHP: to $all_products[] = $temp_set; PHP: , it should be work fine.
this looks cool. going to try it when i get back to office. well i'm doing it because i'm get a whole list of records from 5 tables and displaying them in 1 table. any tables that are not empty gets put inside the $all_products array. only then will another while loop retrieve the data from those resource indexes. maybe there's a easier method by using WHERE condition though...
great! that statement works just fine. problem here was i converted the resource index into arrays with my mediocre understanding of arrays haa.. learned something again. cool. thanks. oh btw, i'm experimenting with the select union command to combine the 5 table's results instead of using php to combine them.