Hello,
I'm working on a script that creates an invoice number based on the current date and the record count returned from the db for a particular year. I'm trying to get the invoice number to be in the form of YYYYMMDDNN where NN represents the count returned from the db. However, I can't simply add the two together because that results in DD being incremented, and if I try to cast the count I get a "Catchable fatal error: Object of class mysqli_result could not be converted to string". Any suggestions?
function get_invoice_number()
{
$year = date("Y");
$today = date("Ymd");
$conn = db_connect();
$count = $conn->query("select count(inv_number) from invoice where inv_number like '$year%'");
if(!$count)
return false;
else
$invnum = $today.(string)$count;
return $invnum;
}
Thanks,
J