title: How can I use array to cut down this block of code by retrieve these captions from a database?
body: <p>So instead of caption1, caption2, caption3 etc, how am I able to just pull the caption from a DB? Probably simple but I'm fairly new so I apologize.</p>
  
  <pre><code>&lt;?php
      $captions = array(
      /*01*/ "caption1",
      /*02*/ "caption2",
      /*03*/ "caption3",
      /*04*/ "caption4",
      ); 
  
      for($n = 1; $n &lt;= count($captions); $n++):
  ?&gt;
  </code></pre>
  
  <p>EDIT:
  And yes I have a DB connected.</p>
  
  <p>Here is my attempt at trying to retrieve the captions. Unfinished yet because I'm not to sure if I'm even going in the right direction.</p>
  
  <pre><code>&lt;?php
              $query = mysql_query("SELECT * FROM images_tbl");
              $array = array();
              while($row = mysqli_fetch_assoc($array)){
              echo $row['caption'];
                          }
  
  
                  $caption = array ( "");
  
                  for($n = 1; $n &lt;= count($caption); $n++):
              ?&gt;
  </code></pre>