title: Search age range in mysql, php
body: <p>Hey guys, I need to make a function so that it will search an age range in this function</p>
  
  <pre><code>    function search($query) {
  
      $query = mysql_escape_string($query);   
      $connection = mysql_open();
      $statement = "select ID, UserName, Gender, USERDOB,DATEDIFF(USERDOB,now()) from Users ";
       if (!empty($query)) {
          $statement .= "where FirstName like '%$query%' " .
                      "or LastName like '%$query%' " .
                      "or UserName like '%$query%' " .
                      "or Gender like '%$query%' ";
                           }
          $statement .= "order by id ";
  
      $result = @ mysql_query($statement, $connection)
       or showerror();
  
    $users = array();
    while ($user = mysql_fetch_array($result)) {
        $user[4] = floor($user[4]/-1/364.25);
        $users[] = $user;
    }
  
    // Close connection and return resulting array
    mysql_close($connection)
        or showerror();
    return $users;
  }
  </code></pre>
  
  <p>This is the function for search. But it also makes it possible to view a persons age. Age is not stored in the database but DOB is. So it calculates that. I also am using a smarty template. 
  mysql_open() is my own function. I figure I need to find a way to get age into the query and do some thing with range...</p>
  
  <p>anyway quite lost, any ideas?</p>