php,从两个表中获取记录

时间:2018-09-08 18:06:44

标签: php sql mysqli

我们有两个名为“学生”和代金券的表。我们创建了费用凭证并显示了凭证,我们还希望显示我们创建凭证的那个特定学生的卷号,但是我们无法获得任何学生表的卷……我们出错了,{ {3}}我在下面添加了代码

      <?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";
        }
    }

?>                 

1 个答案:

答案 0 :(得分:0)

尝试

<?php  if(isset($_POST['many_voucher'])){

    $student_roll = $stu_roll;
}
  ?>