One common way is to use an auto-increment field in the database table where you store the data for each order, and use that number as the reference number (or the basis of it: you might want to add some other info to it). If using MySQL, the [man]mysql_insert_id[/man] can retrieve that number upon completion of the insert query:
// do the insert query for the booking, then create refNumber as the
// current date plus the insert ID (padded with zeros to 8 digits):
$result = mysql_query($insertQuery) or die(mysql_error());
if(mysql_affected_rows())
{
$refNumber = sprintf('%s-%08d', date('Ymd'), mysql_insert_id());
}
else
{
// handle error here....
}