duanjingsen7904 2015-12-07 06:33
浏览 21
已采纳

以输入形式显示来自不同表的字段

How would I display student.Student instead of student_id

 <?php
for ($i = 0; $i < $chkcount; $i++) {
    $id = $chk[$i];
    $res = $MySQLiconn->query("SELECT Student.ID, student.Student, student.School,student.PR, Jumps.dis_ft_1, Jumps.dis_in_1, Jumps.dis_ft_2, Jumps.dis_in_2, Jumps.dis_ft_3, Jumps.dis_in_3, Jumps.dis_ft_4, Jumps.dis_in_4, Jumps.dis_ft_5, Jumps.dis_in_5, Jumps.dis_ft_6, Jumps.dis_in_6
            FROM Student LEFT JOIN Jumps ON Student.ID = Jumps.student_id WHERE ID=" . $id);
    while ($row = $res->fetch_array()) {
        ?>
        <tr>
            <td>
                <input type="hidden" name="id[]" value="<?php echo $row['ID']; ?>"/>
                Student ID: <input type="text" name="st[]" value="<?php echo $row['student_id']; ?>"
                                   class="form-control"/>
                Attempt 1 <input type="text" name="df1[]" value="<?php echo $row['dis_ft_1']; ?>"
                                 class="form-control"/>
                <input type="text" name="di1[]" value="<?php echo $row['dis_in_1']; ?>"
                       class="form-control"/>
                Attempt 2 <input type="text" name="df2[]" value="<?php echo $row['dis_ft_2']; ?>"
                                 class="form-control"/>
                <input type="text" name="di2[]" value="<?php echo $row['dis_in_2']; ?>"
                       class="form-control"/>
                Attemp 3 <input type="text" name="df3[]" value="<?php echo $row['dis_ft_3']; ?>"
                                class="form-control"/>
                <input type="text" name="di3[]" value="<?php echo $row['dis_in_3']; ?>"
                       class="form-control"/>
                Attempt 4 <input type="text" name="df4[]" value="<?php echo $row['dis_ft_4']; ?>"
                                 class="form-control"/>
                <input type="text" name="di4[]" value="<?php echo $row['dis_in_4']; ?>"
                       class="form-control"/>
                Attempt 5 <input type="text" name="df5[]" value="<?php echo $row['dis_ft_5']; ?>"
                                 class="form-control"/>
                <input type="text" name="di5[]" value="<?php echo $row['dis_in_5']; ?>"
                       class="form-control"/>
                Attempt 6 <input type="text" name="df6[]" value="<?php echo $row['dis_ft_6']; ?>"
                                 class="form-control"/>
                <input type="text" name="di6[]" value="<?php echo $row['dis_in_6']; ?>"
                       class="form-control"/>
            </td>
        </tr>
        <?php
    }
}
?>

Not sure it can be done. But Student name would be better than student id. Wouldn't post with more text so just typing so it will post. I am learning PHP.

展开全部

  • 写回答

1条回答 默认 最新

  • douzhangcuo2174 2015-12-07 06:48
    关注

    If there is only one field called Student i.e Student.Student, then you could just output the name <?php echo $row['Student']; ?>.

    However, if there are ever name clashes, you can always give the field a new name for PHP to access.

    SELECT Student.ID, Student.Student AS some_new_name FROM ....
    
    <?php echo $row['some_new_name']; ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?

悬赏问题

  • ¥15 没输出运行不了什么问题
  • ¥20 输入import torch显示Intel MKL FATAL ERROR,系统驱动1%,: Cannot load mkl_intel_thread.dll.
  • ¥15 点云密度大则包围盒小
  • ¥15 nginx使用nfs进行服务器的数据共享
  • ¥15 C#i编程中so-ir-192编码的字符集转码UTF8问题
  • ¥15 51嵌入式入门按键小项目
  • ¥30 海外项目,如何降低Google Map接口费用?
  • ¥15 fluentmeshing
  • ¥15 手机/平板的浏览器里如何实现类似荧光笔的效果
  • ¥15 盘古气象大模型调用(python)
手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部