当前位置: 动力学知识库 > 问答 > 编程问答 >

php - how to show select option value in MySQL

问题描述:

hello I create database 2 table 1 vn_rent 2 amount_cus

from insert to vn_rent

i user code this select option value

<?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> &nbsp; วันที่จองเต็มแล้ว

</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> &nbsp; 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> &nbsp; s] จองรถตู้สำเร็จ โปรดรอการตอบรับทาง Email !

</div>";

}

else

{

$msg = "<div class='alert alert-danger'>

<span class='glyphicon glyphicon-info-sign'></span> &nbsp; error while registering !

</div>";

}

$con->close();*/

?>

Simple Select table amount_cus insert to 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>

[]

[]

OK I'm sorry i'm not good english

What I will do is. I will make changes, but the problem is, I do it to extract data from tables and lists amount_cus selected first. And along with other data

网友答案:

i user code $row

<select class="select-search" name="am_id"> 
<option value="<?php echo $row['am_id'];?>"> <?php echo $row['am_id'];?> </option>

but show incomplete I want to show it , not choice.

For example, I selected five data will show.

5
1
2
3
4
6
7
8
9
10
分享给朋友:
您可能感兴趣的文章:
随机阅读: