title: How to write query for same table same index group
body: <p>combine one SQL queries from same table same index in PHP MySQL but i just try index name news image select table than than fetch this output   view.</p>
  
  <p>this output view  image get to databese both are image but two two grouping view
  how can its sole query throw </p>
  
  <pre><code>[first image get to databese][1]    [third image get to databese][3]  [five  image get to databese][5]    five 7 img ...............
  [second image get to databese][2]    [fourth image get to databese][4] [six image get to databese][6]      six 8   img...............
  </code></pre>
  
  <p>but i try this query but no work</p>
  
  <pre><code>$numrow =0;
  $vali=0;
  $sql_q = mysqli_query($conn,"SELECT * FROM tbl_news where cat_id='$cat_id' and cat_id !=19 order by nid DESC"); 
  $ny = mysqli_fetch_array($sql_q);
  if mysqli_num_rows($sql_q) &gt; 0) {
     while($newsRowi = mysqli_fetch_array($sql_q)){
              $row[]=$newsRowi;
     }
     $n=0;$val=0;
     foreach($row as $newsRow ){    
       $news_img     = $newsRow['news_image'];
       $f_id     = $newsRow['nid'];
       $news_heading = substr($newsRow['news_heading'],0,50);
       $sq = mysqli_query($conn,"SELECT * FROM tbl_news where nid='ny[0]'");
       $ya=mysqli_fetch_array($sq);
       $val = $ya['news_image'];
       $n++;
       $n++;
   }
  ?&gt;
  </code></pre>
  
  <p>please help me</p>