簡體   English   中英

列出使用php的mysql中的記錄,但僅出現一條記錄?

[英]List records in mysql using php but only one record appear?

<tbody>
    <?php
    $teacher_subject_query = mysql_query("select * from teacher_suject where teacher_id='$session_id'") or die(mysql_error());
    $teacher_row = mysql_fetch_array($teacher_subject_query);
    $subject_id = $teacher_row['subject_id'];

    $query = mysql_query("select * from subject where subject_id = '$subject_id'") or die(mysql_error());
    while ($row = mysql_fetch_array($query)) {
        $id = $row['subject_id'];
        ?>
           <!-- script -->
    <script type="text/javascript">
        $(document).ready(function(){

            $('#d<?php echo $subject_id; ?>').tooltip('show')
            $('#d<?php echo $subject_id; ?>').tooltip('hide')
        });
    </script>
    <!-- end script -->
    <!-- script -->
    <script type="text/javascript">
        $(document).ready(function(){

            $('#e<?php echo $subject_id; ?>').tooltip('show')
            $('#e<?php echo $subject_id; ?>').tooltip('hide')
        });
    </script>
    <!-- end script -->

        <tr class="odd gradeX">

            <td><?php echo $row['subject_code']; ?></td> 
            <td><?php echo $row['subject_title']; ?></td> 

這些是我使用的代碼,但是系統中僅顯示一條記錄,我需要全部顯示! 提前致謝!

只能有一條記錄與您的查詢匹配:

$query = mysql_query("select * from subject where subject_id = '$subject_id'") or die(mysql_error());

您正在通過ID獲取特定主題。

采用

$ teacher_subject_query = mysql_query(“ select * from Teacher_suject”)或die(mysql_error());

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM