I want to create an array of values from one table and for each result
create a sub array from a lower table but I keep getting the following error
not a valid MySQL result resource in 
I use the the following query. Isn't this possible? If not what should I
use? Thanks.

$query = "SELECT * FROM article WHERE category_id = $category_id";
$result = $db->query("$query") or die("Select Failed!");
$number = mysql_num_rows($result);
echo "number of rows effected is $number<br>";

$counter=1;
        while ($row = mysql_fetch_array ($menu_result)) {
                $main_id[$counter]              = $row[id];
                $main_title[$counter]           = $row[title];
                echo "$main_title[$counter]";
                echo "$main_id[$counter]";
                
                $subquery = "SELECT * FROM sub_article WHERE article_id
=$main_id[$counter]     ";
                $subresult = $db->query("$subquery") or die("Select
Failed!");
                        $z=1;
                        while ($subrow = mysql_fetch_array ($subresult)) {
                        $sub_id$z]              = $subrow[id];
                        $sub_title[$z]          = $subrow[title];
                        echo "$sub_title[$z]";
                        echo "$sub_id[$z]";
                        $z++;
                }
                
        $counter++;
        }

Reply via email to