#!/bin/bash

source head.sh

echo '
    <div class="container mt-5">
        <h1 class="mb-4">老师列表</h1>
        <table class="table table-bordered">
            <thead>
                <tr>
                    <th>老师号</th>
                    <th>姓名</th>
                    <th>所教科目</th>
                </tr>
            </thead>
            <tbody>
'
# 尝试从缓存读取
sql="select jx_teacher.id, jx_teacher.name, jx_subject.name from jx_teacher  join jx_subject on jx_teacher.subjectId=jx_subject.id;"
source cache.sh

for stu in ${stuList[@]}; do
  # 获取学号、姓名、班级、年龄
  id=$(echo $stu | awk -F "@" '{print $1}')
  name=$(echo $stu | awk -F "@" '{print $2}')
  subject=$(echo $stu | awk -F "@" '{print $3}')
  echo "
                  <tr>
                      <td>$id</td>
                      <td>$name</td>
                      <td>$subject</td>
                  </tr>
  "
done
echo '
            </tbody>
        </table>
    </div>
    
    <!-- 引入Bootstrap的JavaScript文件，用于一些表格交互效果 -->
    <script src="/static/js/bootstrap.min.js"></script>
</body>
</html>
'
