0
I need to display the next id number in an input, in case the form would be for a new sale, then I need it to appear in an input where it says the current sale number q will be made, in case the next id number of table q is auto incriment
next id search script: .
include_once "configbanco.php";
$sql = "select (max(Id) + 1) from venda";
$resultado = mysqli_query($con,$sql);
$result = mysqli_fetch_row ($resultado);
$id = $result;
form that received next id:
<div class="form-row">
<div class="form-group col-md-7 mr-3">
</div>
<label class=" col-form-label mr-1" ></label>
<div class="col-sm-1 mr-3">
</div>
<label for="idvenda" class=" col-form-label mr-3" >Número da Venda</label>
<div class="col-sm-1">
<input class="form-control" id="idvenda" name="idvenda" value="<?php echo $id ?>" required readonly >
</div>
</div>
<hr>
currently displaying "array" as value in the input field
this is not a reliable way to be next and then there may be a new data entry in the database and then change and then no longer valid the number displayed. I don’t know if there is any way to inform the next ID to be incremented unless only the user makes use of your system or with table lock.
– ElvisP
Poise mas n has to be inserted before this form in this table... it’s like in a service order, you have to show the number of the order you are opening, in case the next id of the table to be generated... in case my command select the result in the same database, it shows... I just need it to show the result of this query ...
– Cleiton Back
You can create a TOKEN for this, instead of using the TABLE record ID, which is not safe to use the ID as well as can not have control with multiple sessions making use of the system.
– ElvisP