title: PHP search different fields in a table and show respective results
body: <p>Maybe I'm not thinking this through correctly but I have a company table with:</p>
  
  <pre><code>name
  address
  city
  state
  zip
  </code></pre>
  
  <p>I want to search two fields, name and city.</p>
  
  <p>My query is:</p>
  
  <pre><code>SELECT DISTINCT    city, name 
  FROM               companies 
  WHERE              city 
  LIKE               '%$search%' 
  OR                 name 
  LIKE               '%$search%'
  </code></pre>
  
  <p>and the results code is:</p>
  
  <pre><code>echo '&lt;a href="city.php?city=' . $results['city'] . '"&gt;' 
      . $results['city'] . '&lt;/a&gt;';
  </code></pre>
  
  <p>Now this only takes into account if the person searches for a city.  How do I get it to show the page if someone searches for a company name?  Something like:</p>
  
  <pre><code>echo '&lt;a href="company.php?co=' . $results['name'] . '"&gt;' 
      . $results['name'] . '&lt;/a&gt;';
  </code></pre>
  
  <p>Is there any way to show the proper result depending on what they searched for?</p>