comparing date against database date
Posted: Sun Aug 29, 2010 12:48 pm
so i am try to show users with a date of birth greater or equal to the one select and i cant seem to get the script to work right.
<?php
if ($_GET['gender'] == 'Female') {
$where = "sex='Female'";
}
elseif ($_GET['gender'] == 'Male') {
$where = "sex='Male'";
}
elseif ($_GET['gender'] == 'Both') {
$where = "status='active'";
}
$minAge = $_GET['minAge'];
$minimum = date("m/d/Y", strtotime('-$minAge years'));
$min = " AND date_of_birth =>" . $minimum;
$maxAge = $_GET['maxAge'];
$maximum = date("m/d/Y", strtotime('-$maxAge years'));
if (isset($_GET['single']) == 1) {
$where1 = " AND relationship_status='Single'";
}
else
$where1 = '';
if ($_GET['married'] == 1) {
$where2 = ' AND relationship_status="Married"';
}
else
$where2 = '';
$result = mysql_query("SELECT * FROM users WHERE " . $where . $min . $where2 . " ORDER BY signup_date DESC");
<?php
if ($_GET['gender'] == 'Female') {
$where = "sex='Female'";
}
elseif ($_GET['gender'] == 'Male') {
$where = "sex='Male'";
}
elseif ($_GET['gender'] == 'Both') {
$where = "status='active'";
}
$minAge = $_GET['minAge'];
$minimum = date("m/d/Y", strtotime('-$minAge years'));
$min = " AND date_of_birth =>" . $minimum;
$maxAge = $_GET['maxAge'];
$maximum = date("m/d/Y", strtotime('-$maxAge years'));
if (isset($_GET['single']) == 1) {
$where1 = " AND relationship_status='Single'";
}
else
$where1 = '';
if ($_GET['married'] == 1) {
$where2 = ' AND relationship_status="Married"';
}
else
$where2 = '';
$result = mysql_query("SELECT * FROM users WHERE " . $where . $min . $where2 . " ORDER BY signup_date DESC");