saversites Posted June 17, 2019 Report Posted June 17, 2019 (edited) 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. $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> "); } Edited June 17, 2019 by saversites Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.