Hello, I'm trying to update a database using php. I have to add patient id in the format of 'p99' and if it reaches the highest number it should go to the next alphabet like 'q01'. I have this piece of code but it doesn't seem too be doing the job. What would I have to fix?
if ($_REQUEST["submitter"]=="Save")
{
if ($_REQUEST["patientid"]=="(System Specified)")
{
$queryres=$mydb->query("Select * from patient where PatientID=patientid");
if ($queryres->countReturnedRows()==0)
$patientid=111;
else
{
$queryres=$mydb->query("Select Max(patientid) as mx from patient");
$resultrow=$queryres->fetchRow();
$patientid=$resultrow['mx']+1;
}
$mydb->execute("Insert Into Patient ".
"(PatientId, patientname, address,".
"gender, bloodtype, spam,".
"organs)".
" Values (%i,%s,%s,%s,%i,%b,%b)",
$patientid,
$_REQUEST["patientname"],
$_REQUEST["address"],
$_REQUEST["gender"],
$_REQUEST["bloodtype"],
$_REQUEST["spam"],
$_REQUEST["organs"]);
$onloaddo="alert('Saved new patient ".$patientid."');";
$patientid="";
}
} {