$strSQL2 = "SELECT customer.*, insurance.*, insurancedetial.*,
insurancepay.*, bookingpay2.* FROM insurance
LEFT JOIN insurancedetial ON insurance.insuranceid = insurancedetial.vinnumber
RIGHT JOIN insurancepay ON insurancedetial.insurdetaid = insurancepay.insurdetaid
LEFT JOIN customer ON insurance.insur1 = customer.idcus
LEFT JOIN bookingpay2 ON insurancedetial.insurdetaid = bookingpay2.bookingid ";
$strSQL2 .= " where ";
$strSQL2 .=" and (insurancepay.numpayment = '$p03' and bookingpay2.comple9 = $zero and
'$datenow' > insurancedetial.insud7)