![]() |
having nested mysql_fetch_assoc statements
is it possible to have something like this?
because in the nested query i am getting an error the error says: <b>Warning</b>: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in this is the sql statement: select label from tbl_group order by id Code:
$sql1 = "select * from table"; |
You need to run mysql_query on those sql strings.
Like this: php Code:
mysql_fetch_assoc works on valid mysql result sets and not on strings that are intended to be queries. |
Plus, if you need to nest mysql_fetch_assoc functions, then you'll also need separate database connections ;)
|
Quote:
While it may be recommended that he does a JOIN instead of one query and another, or at least attempt a sub query, I wouldn't say using nested mysql_fetch_assoc() need any type of warning. Just my 2 cents though :P |
It's the same database so multiple connections would be useless. When providing a different source (via a query) PHP will automagically differiate them. (is "differiate" english? :-P)
I think a JOIN in the SQL would be a bit to much for this person at the moment. :) Not to diss him, but he's a beginner so this is enough already :) |
Quote:
|
| All times are GMT. The time now is 01:37 PM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0