你好我创建数据库2表1 vn_rent 2 amount_cus
从插入到vn_rent
我用户编码此选项选项值
<?php
session_start();
//PUT THIS HEADER ON TOP OF EACH UNIQUE PAGE
if(!isset($_SESSION['id_user'])){
header("location:index.php");
header("Content-type: text/html; charset=utf-8");
}
include_once('config/dbconnect.php');
$id_user = $_SESSION['id_user'];
$rn_first_name = $_POST['rn_first_name'];
$rn_last_name = $_POST['rn_last_name'];
$rn_gostart = $_POST['rn_gostart'];
$rn_endstart = $_POST['rn_endstart'];
$time_gostart = $_POST['time_gostart'];
$time_endstart = $_POST['time_endstart'];
$rn_tel = $_POST['rn_tel'];
$rn_amount = $_POST['rn_amount'];
$rn_svan = $_POST['rn_svan'];
$rn_destination = $_POST['rn_destination'];
$id_invoice = $_POST['id_invoice'];
$Status = $_POST['Status'];
$vn_dtial = $_POST['vn_dtial'];
$rn_place = $_POST['rn_place'];
$id_vn_order = $_POST['id_vn_order'];
$travel_id = $_POST['travel_id'];
$province_id = $_POST['province_id'];
$am_id = $_POST['am_id'];
$date = "$rn_gostart"; //กำหนดค้นวันที่
$result = mysqli_query($con,"select * from vn_rent where rn_gostart = '$date'");
$ckd = mysqli_num_rows($result);
if($ckd >= 3){
$msg = "<div class='alert alert-danger'>
<span class='glyphicon glyphicon-info-sign'></span> วันที่จองเต็มแล้ว
</div>";
}else{
$sql = "INSERT INTO vn_rent (id_user,rn_first_name,rn_last_name,rn_gostart,rn_endstart,time_gostart,time_endstart,rn_tel,rn_amount,rn_svan,Status,vn_dtial,rn_place,rn_destination,travel_id,province_id,am_id)
VALUES ('$id_user', '$rn_first_name',' $rn_last_name ','$rn_gostart','$rn_endstart','$time_gostart','$time_endstart','$rn_tel','$rn_amount','$rn_svan','$Status','$vn_dtial','$rn_place','$rn_destination','$travel_id','$province_id','$am_id')";
//คำสั่ง insert 2 ตาราง
if ($con->query($sql) === TRUE) {
$id_van = $con->insert_id;
$con->query("INSERT INTO invoice
(id_user, id_vn_order,id_van)
VALUE($id_user, $id_vn_order, $id_van)");
$id_invoice = $con->insert_id;
$con->query("UPDATE vn_rent
SET id_invoice = '$id_invoice'
WHERE id_van = $id_van");
$msg = "<div class='alert alert-success'>
<span class='glyphicon glyphicon-info-sign'></span> s] จองรถตู้สำเร็จ โปรดรอการตอบรับทาง Email !
</div>";
}
else {
echo "Error: " . $sql . "<br>" . $con->error;
}
}
$con->close();
/*
$sql = "INSERT INTO vn_rent (id_user,rn_first_name,rn_last_name,rn_dstart,rn_estart,rn_tel,rn_amount,rn_svan,Status,vn_dtial,rn_place,rn_destination)
VALUES ('$id_user', '$rn_first_name',' $rn_last_name ','$rn_dstart','$rn_estart','$rn_tel','$rn_amount','$rn_svan','$Status','$vn_dtial','$rn_place','$rn_destination')";
$sql1="INSERT INTO invoice (id_invoice,id_van,id_user,id_vn_order)
VALUES ('$id_invoice', '$id_van',' $id_user ','$id_vn_order')";
if($con->multi_query($sql))
{
$msg = "<div class='alert alert-success'>
<span class='glyphicon glyphicon-info-sign'></span> s] จองรถตู้สำเร็จ โปรดรอการตอบรับทาง Email !
</div>";
}
else
{
$msg = "<div class='alert alert-danger'>
<span class='glyphicon glyphicon-info-sign'></span> error while registering !
</div>";
}
$con->close();*/
?>
简单选择表格amount_cus插入到vn_rent
<?php
include "config.php";
$query = "SELECT * FROM amount_cus";
$result = mysqli_query($mysqli, $query); ?>
<select class="select-search" name="am_id">
<?php while ($line = mysqli_fetch_array($result, MYSQL_ASSOC)) { ?>
<option value="<?php echo $line['am_id'];?>">
<?php echo $line['am_text'];?>
</option>
<?php } ?>
</select>
[]
[]
好的,对不起,我不是很好的英语
我要做的是。我将进行更改,但问题是,我这样做是为了从表格中提取数据并首先选择amount_cus。以及其他数据
答案 0 :(得分:0)
我是用户代码$ row
<select class="select-search" name="am_id">
<option value="<?php echo $row['am_id'];?>"> <?php echo $row['am_id'];?> </option>
但显示不完整我想展示它,而不是选择。
例如,我选择了五个数据显示。
5
1
2
3
4
6
7
8
9
10