graham23s Posted November 18, 2007 Share Posted November 18, 2007 Hi Guys, i have knocked up a basic for with 5 fields to search, i'm having trouble with the between ages selection: code: ## deal with the submission if(isset($_GET['search'])) { echo ("<hr />"); ## vars $gender = $_GET['gender']; $herefor = $_GET['herefor']; $country = $_GET['from']; $frage = $_GET['fromage']; $to = $_GET['toage']; //echo $gender.$herefor.$from.$frage.$to; ## compile the query $searchquery = "SELECT * FROM `users` "; $searchquery .= "WHERE `gender`='" . $gender . "' "; $searchquery .= "AND `herefor`='$herefor' "; $searchquery .= "AND `country`='$country'"; $searchquery .= " AND `year` BETWEEN YEAR(CURDATE() - INTERVAL $toage YEAR) AND YEAR(CURDATE() - INTERVAL $fromage YEAR)"; ## run query $resultquery = mysql_query($searchquery); ## num results $numresults = mysql_num_rows($resultquery); echo $numresults; } when the user selects between 18 and 50 for example, i assume thats where the problem lies is there a better way to do that all? thanks guys Graham Quote Link to comment https://forums.phpfreaks.com/topic/77819-searching-mysql/ Share on other sites More sharing options...
fenway Posted November 19, 2007 Share Posted November 19, 2007 You're storing just the year? Quote Link to comment https://forums.phpfreaks.com/topic/77819-searching-mysql/#findComment-394459 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.