title: How do I call data from the database as an array and then echo each value from the array?
body: <p>I'm new to coding.</p>
  
  <p>CONTEXT
  I have one table 'online_event' that holds the details to my event page. I have another table 'event_gallery' that holds the photos to the same event page. The primary key in 'online_event' is the foreign key in 'event_gallery'</p>
  
  <p>so one event from 'online_event' can have multiple photos inside the 'event_gallery' table.</p>
  
  <p>I'm able to retrieve one photo in the event_gallery table by using the foreign key (which is just the event id).</p>
  
  <p>My question is, how can I call all pictures? it's only echoing the first of 3 photos i have saved in the table with that id number.</p>
  
  <pre><code>$gallery_table =  Eventgallery::find_by_id($_GET['id']);
          if($gallery_table){
  
              $images = $gallery_table-&gt;image_name;
  
          }
  
        print_r($images);
  </code></pre>
  
  <p>Here is the function that retrieves the data</p>
  
  <pre><code>
    public static function find_by_id($id){
      global $database;
      $the_result_array = static::find_by_query("SELECT * FROM " . static::$db_table. " WHERE id = $id");
          return !empty($the_result_array) ? array_shift($the_result_array) : false; //ternary operator
  
      }
  </code></pre>
  
  <p>Because the method is returning an array_shift, shouldn't the variable I created ($images) be an array? When I print_r() it comes out as just 1 result, not an array.</p>
  
  <p>Once I have it as an array, i want to loop through it and echo it all out.</p>
  
  <p>Thank you</p>