Hi to All! Respected member of this forum Miss Lara help me alot to solve the issue but I am facing one issue with that code,When Instead of B, if i used two latter (for example “BA” instead of only B) then its stop incrementing the number for next entry in the form.
<?php // Get the current month and year as two-digit strings
$month = date("m");
$year = date("y");
// e.g. 23
// Get the last bill number from the database
$query = "SELECT patientno FROM iap2 ORDER BY patientno DESC";
$result = mysqli_query($conn,$query);
// Use mysqli_fetch_assoc() to get an associative array of the fetched row
$row = mysqli_fetch_assoc($result);
// Use $row['patientno'] to get the last bill number
$lastid = $row['patientno'];
// Check if the last bill number is empty or has a different month or year
if(empty($lastid) || substr($lastid, 2, 2) != $month || substr($lastid, 4, 2) != $year) {
// Start a new sequence with 0001
$number = "Ls-$month$year-0001";
}
else
{
// Increment the last four digits by one
$idd = substr($lastid, 8);
// e.g. 0001
$id = str_pad($idd + 1, 4, 0, STR_PAD_LEFT);
// e.g. 0002
$number = "Ls-$month$year-$id";
}
?>