In my example I have a PHP script that, from AJAX, does a tally of everyone named 'Richard.' I would like to further modify this by counting the people named Richard, that match the age of some input value, as shown in $theirage.
Specifically, I would like to sum up the two ages, and only show the ones that equal 20 in my array. $row[age] corresponds to the value age in my DB, while $theirage is a user input.
At the end I want to only tally the summed ages that equal to 20, in this case.
$theirage = $_GET['theirage'];
$query = mysqli_query($con, "SELECT count(*) as cnt FROM members WHERE
name = 'Richard'
");
$row = mysqli_fetch_assoc($query);
$bow = $row['age'] + $theirage;
$if ($bow = 20){
$person = $row['cnt'];}
echo json_encode( array(
'person' => $person
) );
How might I go about this?