找到你要的答案

Q:How to echo and auto increment receipt number in php?

Q:如何呼应和PHP自动增量的收据号码吗?

I have a database, and table fees. In which I have to generate a receipt of each payment. But I want that receipt number field must first echo receipt number which is one increment (+1) of last receipt number. For example, last receipt is 1 than new receipt should be 2 and non editable.

I am bit confused in that.

My field code is:

<label class="field-title">Reciept Number <span class="form-req">*</span></label>
<input type="text" name="reciept_number" class="span4" value="<?php 

$data =  max(mysqli_fetch_array(mysqli_query($conn,"SELECT reciept_number FROM fees"))); echo $data; ?>" readonly>

我有数据库,还有表费。其中我必须生成收据的每个付款。但我希望收据号码字段必须首先收到收据号码,这是最后收据号码的一个增量(1)。例如,去年收到的1比新收据应2和非编辑。

我有点困惑。

我的字段代码是:

<label class="field-title">Reciept Number <span class="form-req">*</span></label>
<input type="text" name="reciept_number" class="span4" value="<?php 

$data =  max(mysqli_fetch_array(mysqli_query($conn,"SELECT reciept_number FROM fees"))); echo $data; ?>" readonly>
answer1: 回答1:

Dont understand your question exactly but maybe you want something like this:

<label class="field-title">Reciept Number <span class="form-req">*</span></label>
                                <input type="text" name="reciept_number" class="span4" value="
<?php 
$data = mysqli_fetch_row(mysqli_query($conn,"SELECT max(reciept_number)+1 FROM fees")); 
echo $data[0]; 
?>" readonly>

不明白你的问题,但也许你想要这样的东西:

<label class="field-title">Reciept Number <span class="form-req">*</span></label>
                                <input type="text" name="reciept_number" class="span4" value="
<?php 
$data = mysqli_fetch_row(mysqli_query($conn,"SELECT max(reciept_number)+1 FROM fees")); 
echo $data[0]; 
?>" readonly>
php  mysql