Sooraj Abbasi Sooraj Abbasi - 8 months ago 24
MySQL Question

I am working on a php project where i want to get the most recent date from my database table

Here is my code: here is a table from which i want to retrieve the most recent payment paid by buyer.

$query3=mysql_query("SELECT *FROM paid_m_installments WHERE plot_id='$pid' AND buyer_id='$uid'");
while ($rows = mysql_fetch_assoc($query3)) {
$paid_dates =date('d-m-Y',strtotime($paid_dates_r=$rows['install_paid_date']));
echo "THere is error";
echo $last_date;


You just need to get the most recent date by sql, no need to loop result by php:

SELECT STR_TO_DATE(install_paid_date, '%d-%m-%Y') AS install_paid_date 
FROM paid_m_installments
WHERE plot_id='$pid' AND buyer_id='$uid'
ORDER BY install_paid_date DESC