title: php mysql select only matches column
body: <pre><code>          Mysql Database-
  
           id | username | folder_name |
            1 | ashly    | Folder      |
            2 | ashly    |             |
            3 | ashly    |             |
            4 | ashly    | Folder      |
            5 | ashly    | Folder      |
            6 | ashly    | Folder 1    |
            7 | ashly    | Folder 2    |
  
  
             $sql = mysql_query("SELECT `id`, `username`, `title`, LEFT(`description`, 90) as `description`, `file`, `code`, `folder_name`, `type`, `size`, `date` FROM `files` WHERE `username` = '$userfile' AND `folder_name` &gt; '' ORDER BY `id` DESC LIMIT 1, 5");
  
  
         while ($query_row = mysql_fetch_array($sql2)) {
              $filefolder = $query_row['folder_name'];
              $filetitle = $query_row['title'];           
              $filecode = $query_row['code'];
              $filedesc = $query_row['description'];
              $filefile = $query_row['file'];
              $filesize = $query_row['size'];
              $filedate = $query_row['date'];
              $filetype = $query_row['type'];
  </code></pre>
  
  <p>// here I loop for result</p>
  
  <pre><code>        if (empty($filefolder) === false) {
      echo "" . $filefolder . "&lt;div id='imageshowsearch'&gt;&lt;div id='linkstyle'&gt;&lt;strong&gt;&lt;a href='http://localhost/edu/1111111111111/userdownload.php?code=". $filecode . " '&gt;&lt;img src='files/thumbs/" . $filecode . "/" . $filefile . "' alt=" . $filetitle . "&gt;" . $filetitle . "&lt;/strong&gt;&lt;/div&gt;&lt;/a&gt;&lt;/div&gt;";
  
       //here print result 
              }
               }
  </code></pre>
  
  <p>I can't get show <code>folder_name</code> only once.With 5 images from folder.| When I loop it for mysql result.  </p>
  
  <pre><code>     Result:   
  
      folder        | folder         | folder         | folder 1      | folder 2
      here is image | here is image  | here is image  | here is image | here is image
  
     I wonna get this result:     
  
     folder          |
     here is image   | here is image   | here is image |
  
     folder 1        |
     here is image   |
  
     folder 2        |
     here is image   |
  </code></pre>
  
  <p>I don't have a idea. How I can display folder name only once and under folder name show max 5 images from some folder. Just I don't wonna repeat folder name with every single image. I must group folder name with folder images with user images. My problem is only for these folder name repeat... Thanks for support I am writing because website don't allow me to publish my question 'more code no explain'</p>