尝试根据下拉菜单中的选择检索MySQL数据

时间:2019-07-09 11:16:15

标签: javascript php html

我目前正在从事LMS项目。当学生归还一本书时,我试图获取预期的书交付日期,以决定是否按时归还这本书。

我有2个php文件。当尝试从下拉菜单中选择一个选项时,我试图将book_return.php中的某些值传递给retrieve_expected_book_delivery_date.php。理想情况下,该函数应返回最新的预期书交付日期,但不返回任何内容。

book_return.php

<script>
            $(document).ready(function() {
            $("#select1").change(function(){
             var book_id = $("#book_id").val(); 
             var book_title = $("#book_title").val();
             var book_author = $("#book_author").val();
             var student_id = $("#student_id").val(); 
             var student_course = $("#student_course").val();
             var select1 = $("#select1").val();
             $.post("retrieve_expected_book_return_date.php", {book_id:book_id, book_title:book_title, 
             book_author:book_author, student_id:student_id, student_course:student_course, student_semester:select1},
                    function(data){
                                    **$("#exp_return_date").val(data[0]);
                                    });**
            });
        });
</script>

retrieve_expected_book_return_date.php

$sql = "select MAX(expected_return_date) as exp_date 
from books_issue bi 
where  
bi.book_id = '$b_id' 
AND bi.book_title = '$b_title' 
AND bi.book_author = '$b_author'
AND bi.student_id = '$s_id' 
AND bi.student_course = '$s_course' 
AND bi.student_semester = '$s_semester' ";
//echo $sql;
$result = mysqli_query($con,$sql);
if(!$result)
    {
        echo "No records matching your query were found.";  
    }
    else
    {   
        $student_data = mysqli_fetch_array($result);
        $exp_del_date = $student_data['exp_date'];
        **echo $exp_del_date;**
    }

基本上,我想将预期的交付日期分配给文本框值。

0 个答案:

没有答案
相关问题