我在同一页面中使用两个按钮“获取”和“提交”。当我单击“获取”按钮时,我从一个表 [ticket Generation] 获取值并显示在表单中,并且获取工作正常。当我尝试将获取记录插入另一个表[详细信息]时,记录未插入。
HTML PART
<div class="col-sm-3">
<center><input type="submit" name="fetch" id="fetch" class="btn btn-primary" value="Fetch Records" style="padding: 4px 10px 4px 10px;float:right;"></center>
</div>
<div class="col-sm-3">
<center><input type="submit" name="submit" id="submit" class="btn btn-primary" value="Submit" style="padding: 4px 10px 4px 10px;float:left;"></center>
</div>
PHP PART
if (isset($_POST['fetch'])) {
$ticketid1 = $_POST['tid'];
$sel = "select * from ticketgeneration where ticket_id='$ticketid1'";
$res = mysqli_query($conn,$sel);
$row = mysqli_fetch_array($res);
}
上面的代码从“ticket Generation”表中获取值并显示在文本框中
<input type="text" class="form-control" name="custname" id="custname" value="<?php echo $row['customer_name'];?>">
当我尝试将获取的值插入其他表[详细信息]时,它没有插入。
if(isset($_POST['submit'])) {
$ticketgendate = $_POST['date'];
$ticketid = $row['ticket_id'];
$customername = $row['customer_name'];
...
$ins = "insert into details (date,ticket_id,customer_name,...)values (('$ticketgendate','$ticketid','$customername',...)";
$res = mysqli_query($conn,$ins);
我是否在某处缺少条件...
叮当猫咪
12345678_0001