title: Using data from first mysqli query in second query and nesting results
body: <p>I have multiple tables I am joining to use in results for a second query and nesting the second results inside the first results.</p>
  
  <p>I am using the following code:</p>
  
  <pre><code>$result = mysqli_query($con,"SELECT info.lotto_id, info.name, info.number_balls, info.number_bonus_balls, info.db_name, country.name_eng AS country, currency.name AS currency, currency.symbol AS symbol, next.draw_date AS next_draw, next.jackpot AS next_jackpot
  FROM info
  LEFT JOIN country ON info.country_id = country.id_country 
  LEFT JOIN currency ON info.currency_id = currency.currency_id
  LEFT JOIN next ON info.lotto_id = next.lotto_id
  WHERE (info.active='1')
  ORDER BY next_jackpot DESC");
  
  while($lotto = mysqli_fetch_array($result))
  
  {
  
      echo "&lt;table border='0' width='600px' align='center'&gt;";
      echo "&lt;tr&gt;";
      echo "&lt;td&gt;";
      echo "&lt;h1&gt;Results for:&lt;/h1&gt;";
      echo "&lt;/td&gt;";
      echo "&lt;td align='right'&gt;";
      echo "&lt;p&gt;&lt;img src='images/". $lotto['lotto_id'] ."_big.png' alt='". $lotto['name'] ." Results'/&gt;&lt;/p&gt;";
      echo "&lt;/td&gt;";
      echo "&lt;/tr&gt;";
      echo "&lt;/table&gt;";
  
  $result2 = mysqli_query($con,"SELECT * FROM" .$lotto['db_name'].
  "ORDER BY date DESC
  Limit 3");
  
  while($draw = mysqli_fetch_array($result2))
  
    {
      echo "&lt;table class='results' align='center'&gt;";
      echo "&lt;tr&gt;";
      $draw['display_date'] = strtotime($draw['date']);
  $lotto['cols'] = $lotto['number_balls'] + $lotto['number_bonus_balls'];
      echo "&lt;td class='date' colspan='".$lotto['cols']."'&gt;".date('D M d, Y', $draw['display_date']). "&lt;/td&gt;";
  
  if ($draw[jp_code] &lt; "1")
  {
      echo "&lt;td class='winner' align='center'&gt;Jackpot Amount&lt;/td&gt;";
  }
  else
  {
      echo "&lt;td class='rollover' align='center'&gt;Rollover Amount&lt;/td&gt;";
  } 
  </code></pre>
  
  <p>It is giving me the following error: Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in /home/content/95/11798395/html/results/info_mysqli.php on line 59</p>
  
  <p>This relates to my results2 query. Can somebody please suggest what I am doing wrong.</p>
  
  <p>Thank you.</p>