title: Output a series of images from a db into a variable?
body: <p>I have a number of images in my db and they all correspond to the same project ID.</p>
  
  <p>I want them to be displayed next to each other in the browser.</p>
  
  <p>But the following code is output only the latest image but not all of them:</p>
  
  <pre><code>//get all the images in this project and add them to the content variable for output
  
                  if (!empty($FormProjectID)) {
  
                      $DBQuery3 = mysqli_query($dblink, "SELECT * FROM images WHERE project_id = '$FormProjectID'");
  
                      if (mysqli_num_rows($DBQuery3) &lt; 1) {
                          $content = '
                              &lt;p&gt;This project is empty. &lt;a href="index.php?page=upload&amp;id='.$FormProjectID.'"&gt;Upload&lt;/a&gt; some files to get started.&lt;/p&gt;
                          ';
                      } else {
  
                          while($row = mysqli_fetch_array($DBQuery3)) {
                              $DBImageID = $row['image_id'];
                              $DBProjectID = $row['project_id'];
                              $DBImageName = $row['image_name'];
                              $DBImageDescription = $row['image_description'];
                              $DBDateCreated = $row['date_created'];
                              $DBLinkToFile = $row['link_to_file'];
                              $DBGivenName = $row['given_name'];
  
                              //if the image was given a name by the user, display it
                              //otherwise display the generated name
  
                              if (strlen($DBGivenName) &gt; 1) {
                                  $FileName = $DBGivenName;
                              } else {
                                  $FileName = $DBImageName;
                              }
  
                              $content = '
                                  &lt;div class="image"&gt;
                                  &lt;a href="index.php?page=image&amp;id='.$DBImageID.'"&gt;&lt;img src="'.$DBLinkToFile.'" alt="'.$FileName.'" title="'.$FileName.'"/&gt;&lt;/a&gt;
                                  &lt;/div&gt;
                              ';
                      }
                  }
  </code></pre>
  
  <p>How do I get all the image so that in the end the html looks like this:</p>
  
  <pre><code>&lt;div class="image"&gt;
                                  &lt;a href="index.php?page=image&amp;id='.$DBImageID.'"&gt;&lt;img src="'.$DBLinkToFile.'" alt="'.$FileName.'" title="'.$FileName.'"/&gt;&lt;/a&gt;
                                  &lt;/div&gt;
  &lt;div class="image"&gt;
                                  &lt;a href="index.php?page=image&amp;id='.$DBImageID.'"&gt;&lt;img src="'.$DBLinkToFile.'" alt="'.$FileName.'" title="'.$FileName.'"/&gt;&lt;/a&gt;
                                  &lt;/div&gt;
  &lt;div class="image"&gt;
                                  &lt;a href="index.php?page=image&amp;id='.$DBImageID.'"&gt;&lt;img src="'.$DBLinkToFile.'" alt="'.$FileName.'" title="'.$FileName.'"/&gt;&lt;/a&gt;
                                  &lt;/div&gt;
  </code></pre>
  
  <p>Later on in my html page I have:</p>
  
  <pre><code>&lt;?php echo $content; ?&gt;
  </code></pre>