title: Fix query to fetch all rows matching a query into associative array instead of just one
body: <p>In by Database, there are 6 rows where city_name equals "San Antonio" (identical in spelling, capitalization, and spacing). I have the following code for my selection of location id's.</p>
  
  <pre><code>function search_locations(string $term): array
  {
  
      global $db;
  
      $sql = 'SELECT location_id FROM cities
              WHERE
              city_name LIKE :term';
      $stmt = $db-&gt;prepare($sql);
      $stmt-&gt;bindparam(':term', $term);
      $stmt-&gt;execute();
  
      return $stmt-&gt;fetchAll(PDO::FETCH_ASSOC);
  }
  </code></pre>
  
  <p>When I run that command within my function and then check the array using</p>
  
  <pre><code>&lt;?php $id_array = search_locations($search_term); ?&gt;
  &lt;pre&gt;
  &lt;?php print_r( $id_array); ?&gt;
  &lt;/pre&gt;
  </code></pre>
  
  <p>I get the following</p>
  
  <blockquote>
  <pre><code>Array (
  [0] =&gt; Array
      (
          [location_id] =&gt; 38
      )
  
  )
  </code></pre>
  </blockquote>
  
  <p>This only shows one location is being found. BUT if add into my query the following before my return statement</p>
  
  <pre><code>$cSql = 'SELECT COUNT(*) FROM cities WHERE city_name LIKE :term';
  $cStmt = $db-&gt;prepare($cSql);
  $cStmt-&gt;bindParam(':term', $term);
  $cStmt-&gt;execute();
  
  // To just see the result without violating return rules
  exit($cStmt-&gt;fetchColumn()); 
  </code></pre>
  
  <p>I get 6 results. Keep in mind I have also changed the first query to say </p>
  
  <pre><code>    $sql = 'SELECT * FROM cities
              WHERE
              city_name LIKE :term';
  </code></pre>
  
  <p>and still only got one element within the main array with all the field values for only the first row that appears in the table with that city_name equal to "San Antonio"</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>After putting the concise code through the file I noticed that this result doesn't happen if I just call the code as placed above. But there is more code involved that I didn't think was related. Adding that below now.</p>
  
  <pre><code>&lt;?php
  require_once '../../private/initialize.php';
  if (is_post_request() &amp;&amp; $_POST['search_term'] !== "") {
      $search_term = $_POST['search_term'];
      $id_array = search_locations($search_term);
      // Its Fine here
      echo '&lt;pre&gt;';
      print_r( $id_array);
      echo '&lt;/pre&gt;';
  
      $location = [];
      $cities = [];
      $zips = [];
      $phones = [];
      $urls = [];
      foreach ($id_array as $item) {
          array_push($location, find_location_by_id($item['location_id']));
          array_push($cities, find_cities_by_location_id($item['location_id']));
          array_push($zips, find_zips_by_location_id($item['location_id']));
          array_push($phones, find_phones_by_location_id($item['location_id']));
          array_push($urls, find_urls_by_location_id($item['location_id']));
      }
  } else {
      redirect_to(url_for('lookup/test_search.php'));
  }
  
  $page_title = 'Results for "' . $search_term . '"';
  include_once SHARED_PATH . '/search_header.php';
  
  if (!empty($id_array)) { ?&gt;
      &lt;?php
      if (sizeof($id_array) === 1) {
          // Its bad here
          echo '&lt;pre&gt;';
          print_r( $id_array);
          echo '&lt;/pre&gt;';
  } ?&gt;
  </code></pre>