I am creating an admission form for a school, what I want to achieve is that I don't want the users to write form number themselves but generate a form ID based on previously inserted record. I tried fetching the result by executing query:
$query = "SELECT MAX(id) FROM studentAdmissionFormData;
$result = mysqli_query($conn, $query);
while($row = mysqli_fetch_array($result))
{
echo ++$row['id'];
}
mysqli_close($conn);
I am using this code inside value attribute so it should go directly into value but it is returning empty. to check this I used a conditional statement and it verified that query is returning empty.
Now what I want to accomplish is that whenever the page is loaded a Form Number is automatically set, based on what was the number of previous ID.
I's using the above PHP code inside value attribute of <input class="form-control" type="text" name="formNumber" value="">