title: Generating A Dropdown Menu from an API call in PHP
body: <p>I'm a beginner programmer in PHP. For practice, I'm calling an API from A View From My Seat (www.aviewfrommyseat.com), which is a website that lets people upload pictures taken from their seats at certain venues.</p>
  
  <p>What I would like to write is an application where people type in the venue name, and a dropdown list will immediately come up with a list of available sections. There is an API to call the sections, but I need to figure out the proper syntax to populate the list. I Frankenstein-ed together some code from other Stack Overflow answers I've found, but nothing is really working.\</p>
  
  <p>Anyway, here is the list I'm trying to access -- the different sections of each venue.
  <a href="https://i.stack.imgur.com/RokDt.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/RokDt.png" alt="enter image description here"></a></p>
  
  <p>Here's the first part of the PHP code (fetches the URL)
      
  
  <pre><code>if (!empty($_GET['venue'])) {
      $venue_url = 'https://aviewfrommyseat.com/avf/api/venue.php?appkey=API_KEY&amp;venue=' . urlencode($_GET['venue']) . '&amp;section_list=true';
  $venue_json = file_get_contents($venue_url);
  $venue_array = json_decode($venue_json, true);
      }
  ?&gt;
  </code></pre>
  
  <p>This second part is the actual HTML section with the button.</p>
  
  <pre><code>&lt;body&gt;
      &lt;h1&gt; Search for a Venue&lt;/h1&gt;
  &lt;div class = "middle_box"&gt;
      &lt;p&gt; Enter in a venue to get more info about it and to view available    sections. &lt;/p&gt;
  &lt;form action=""&gt;
      &lt;input type = "text" name = "venue" /&gt;
      &lt;button type="submit"&gt;submit &lt;/button&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>And here is where I try to use PHP to populate the different sections that pop up:</p>
  
  <pre><code>&lt;?php
  if(!empty($venue_array)) { 
      echo "&lt;p&gt; Here are the available sections for {$venue_array['avfms'][0]['name']}. Select one to view seats. &lt;/p&gt;";
      echo "&lt;select name =\"section\" id =\"section\"&gt; 
        &lt;option selected=\"selected\"&gt;Choose one&lt;/option&gt;
  foreach($venue_array['avfms'][0]['section'] as $section) {
    &lt;option value=\"&lt;?= $section['section']\"&gt;&lt; $section['section']&gt;&lt;/option&gt;\"
      &lt;/select&gt;";
  }
   ?&gt;
  
      &lt;/div&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Can anyone help me out? </p>