php - php, Record Fetch from two tables
问题描述
we have two tables name "students" AND vouchers. we create the voucher of the fee and display voucher, and we also want to display the roll no of that particular student which was we create voucher, but we can't get the roll any of student table ... we got error,enter image description here I've added the code below
<?php if(isset($_GET['session_id'])):?>
<?php $student_session= $_GET['session_id'];?>
<?php
$stu = "select * from students where
session_id='$student_session'";
$run_stu = mysqli_query($con,$stu);
while($row = mysqli_fetch_array($run_stu)){
$stu_id = $row['student_id'];
$stu_roll = $row['roll_no'];
$stu_name= $row['s_name'];
?>
<?php
if (isset($_POST['many_voucher'])){
$student_roll = $_GET['roll_no'];
$student_session_post = $_GET['session_id'];
$fee_date = $_POST['fee_date'];
$adm_fee = $_POST['adm_fee'];
$reg_fee = $_POST['reg_fee'];
$tution_fee = $_POST['tution_fee'];
$lab_fund = $_POST['lab_fund'];
$misc_dues = $_POST['misc_fund'];
$others = $_POST['others'];
$total_amount = $_POST['total_amount'];
$due_date = $_POST['due_date'];
$remarks = $_POST['remarks'];
$query = "Insert INTO vouchers(session_id,roll_no,fee_month,adm_fee,reg_fee,tution_fee,lab_fund,misc_dues,other_dues,total_amount,due_date,remarks)
VALUES('$student_session_post','$student_roll','$fee_date','$adm_fee','$reg_fee','$tution_fee','$lab_fund','$misc_dues','$others','$total_amount','$due_date','$remarks')";
if(mysqli_query($con,$query)){
//echo "<script>alert('Run')</script>";
}else{
echo"query failed";
}
}
?>
解决方案
try with this
<?php if(isset($_POST['many_voucher'])){
$student_roll = $stu_roll;
}
?>
推荐阅读
- php - CakePHP 4 查找表的函数覆盖?
- json - 如何使用 GopherJS 和 JSON 进行 POST 请求
- c++ - fmtlib:在结果字符串中返回部分格式化数字的 API?
- r - 如何编写一个for循环,其中索引用于在列中查找值
- reactjs - 一张表中的多个过滤器
- xml - JetbrainsMPS 从外部访问 OpenAPI
- node.js - docker-compose:未能解决:rpc 错误:代码 = Unknown desc = 无法计算缓存键
- sql - Sql(不在)运算符查询被忽略
- laravel - 如何在 Laravel 中使用 WhereHas 获取数据 HasMany()
- node.js - Laravel mix npm run dev on linux 在参数列表后产生 SyntaxError: missing )