samedi 21 mars 2020

PHP random filter age

again i have a problem. I want to do a system where you can filter age and sex and get a user from it. I think i've done everything right but i dont get any response from server. Here's my code.

if (isset($_POST['filtruj'])){
    $sex = $_POST['sex'];
    $agemin = $_POST['agemin'];
    $agemax= $_POST['agemax'];
    $lower = date('Y-m-d', strtotime('today -'.$agemin.'years'));
    $upper = date('Y-m-d', strtotime('today -'.$agemax.'years'));

    $sql= "SELECT * FROM  users WHERE age >= '$lower' AND age < '$upper' ORDER BY RAND () LIMIT 1 ; ";
    $result = mysqli_query($conn, $sql);
    $resultCheck = mysqli_num_rows($result);        
    if ($resultCheck> 0){
        $row = mysqli_fetch_assoc($result);
        echo $row['uidUsers'];        


    }        



    }



Aucun commentaire:

Enregistrer un commentaire