I'm having issues getting a PHP MySQL query to return the highest value!
Already tired fixes like the exaple here: SQL select only rows with max value on a column. But this fix had the opposite effect.
$sql = "SELECT * FROM famous_birthdays WHERE sdob = '$today' ORDER BY score
DESC LIMIT 1";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
Here is the output of the code above:
The number below the celebrity names and the Featured Birthday (yes I'm aware that featured is spelt incorrectly) is the score and the Featured birthday should be the celebrity with the highest score but as you can see that's not the case.
The Other Famous Birthdays box is populated using the following code:
$sql = "SELECT * FROM famous_birthdays WHERE sdob = '$today' AND name !=
'$s_name' ORDER BY score DESC ";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {