0

guys, I am stuck here as I am trying to store all the data into row_cats and then call one by one.

$get_cats = "select * from categories";

$get_cats .= "select * from products order by rand() LIMIT 0,4"

$run_cats =mysqli_multi_query($con,$get_cats);

while($row_cats=mysqli_fetch_array($run_cats)){

     $cat_id = $row_cats['cat_id'];//from first query

     $cat_title = $row_cats['cat_title'];
     $pro_id=$row_products['products_id'];//from second query
     $pro_title=$row_products['product_title'];
     $pro_cat=$row_products['cat_id'];
     $pro_image=$row_products['product_img1'];
S.I.
  • 3,250
  • 12
  • 48
  • 77

1 Answers1

-2

You can try

 $get_cats = "select * from categories;";    **// give semicoln inside the double quotes**

 $get_cats .= "select * from products order by rand() LIMIT 0,4"

// Execute multi query
if (mysqli_multi_query($con,$get_cats))
{
 do
 {
  // Store first result set
   if ($result=mysqli_store_result($con)) {
   // Fetch one and one row
   while ($row=mysqli_fetch_row($result))
    {
    printf("%s\n",$row[0]);
    }
   // Free result set
   mysqli_free_result($result);
   }
 }
 while (mysqli_next_result($con));
}
Nishant Nair
  • 1,999
  • 1
  • 13
  • 18