Php Experts,
I need to fetch not the last row in the table but the last entry based on a condition. I only know how to fetch the last row in the table.
I tried coding the way I think it is done but no luck. Googled but no luck.
[code]
$query_for_today_date_and_time = “SELECT date_and_time FROM logins WHERE username = ? ORDER BY id DESC LIMIT 1”;
if($stmt_for_today_date_and_time = mysqli_prepare($conn,$query_for_today_date_and_time))
{
mysqli_stmt_bind_param($stmt_for_today_date_and_time,’s’,$db_username);
mysqli_stmt_execute($stmt_for_today_date_and_time);
$result_for_today_date_and_time = mysqli_stmt_bind_result($stmt_for_today_date_and_time,$db_today_date_and_time);
mysqli_stmt_fetch($stmt_for_today_date_and_time);
$today_date_and_time = $db_today_date_and_time;
mysqli_stmt_close($stmt_for_today_date_and_time);
}
else
{
mysqli_stmt_close($stmt_for_today_date_and_time);
mysqli_close($conn);
die(“<h1 style=”font-family:courier; color:red; text-size:25%; text-align:center”><b>
ERROR STATEMENT 11: Sorry! Our system is currently experiencing a problem! </b></h1> <br>
“);
}