I want to find out the max value of sql data column on the basis of email id and username. (there is no primary entity) To get the email id, i store the user email id from session.
here goes my code:
$emailid = $userRow['emailid'];
$sql = "select max(item) from product where email = '$emailid' AND username = 'arun'";
$result = $conn-> query($sql);
$row = $result->fetch_assoc();
echo "Max item : " .$row['result'];
It's giving me first value of sql table but not highest.
"SELECT MAX(item) AS result FROM product WHERE email = '$emailid' AND username = 'arun'"try this$sql = "select item from product where email = '$emailid' AND username = 'arun' order by item desc limit 1";?