Before delving, one thing is clear:
You did not execute the query for $ result, do not retrieve it and the query $ result1 that you use, which is impossible,
A similar problem exists with $ result1
You can use:
$result = mysql_query('select * from table1');
while($fetch_result=mysql_fetch_array($result))
{
$result2 = mysql("select * from table2 where table1_id = '".$fetch_result['table1_id']."'");
while($fetch_result2=mysql_fetch_array($result2)
{
--your code--
But it is preferable to write JOIN instead of these two queries
source
share