gpt4 book ai didi

javascript - 显示数据和单选按钮并使用数据保存单选按钮的选定值

转载 作者:搜寻专家 更新时间:2023-10-31 21:59:11 24 4
gpt4 key购买 nike

您好,有一个数据库,如下所示,正在从 PHP 获取数据,但是有一个问题需要显示所有 StudentFirstName 的单选按钮,如下所示,并将数据发送回另一个表数据库各自选定的单选按钮值。在按钮上单击注册 ID 可以用作存储在数据库中的主键。

数据库

 SchoolID   StudentRegID    StudentFirstName StudCourse   StudentSection 
FT001 12KQC31085 ABC BCOM A
FT001 12KQC31086 DEF BCOM A
FT001 12KQC31087 GHI BCOM A
FT001 12KQC31088 JKL BCOM A

数据库

 SchoolID   StudentRegID    StudentFirstName StudCourse   StudentSection  Status
FT001 12KQC31085 ABC BCOM A Absent
FT001 12KQC31086 DEF BCOM A Leave
FT001 12KQC31087 GHI BCOM A Absent
FT001 12KQC31088 JKL BCOM A Present

PHP 脚本

$mysqli=mysqli_connect('localhost','Uname','Pass','Database');

//data from ajax
$standard1 = trim($_POST["tclass"]);
$section1 = trim($_POST["tsection"]);
$SchoolID1 = trim($_POST["tschoolid"]);

$query3="SELECT * FROM euser_student WHERE StudCourse='$standard1' and SchoolID='$SchoolID1'and StudentSection='$section1' order by StudentFirstName ASC";
$data3=mysqli_query($mysqli,$query3)or die(mysqli_error());

while($row=mysqli_fetch_array($data3)){
$dat3 = $row['StudentFirstName'];

echo "<table><tr><td>"$dat3."</td></tr><table>";
}
  1. 期待输出

                ABC         O Present   O Absent    O Leave
    DEF O Present O Absent O Leave
    GHI O Present O Absent O Leave
    JKL O Present O Absent O Leave

3.发送选定的值

最佳答案

<table><tr><td>"$dat3."</td><td><input type="radio" name='si".$stydentregid."' value="Present">Present</td><td><input type="radio" name='si".$stydentregid."' value="Absent">Leave </td><td><input type="radio" name='si".$stydentregid."' value="Leave">Absent</td></tr><table>在创建表列时在上面创建。提交时获取单选按钮列表的值。

关于javascript - 显示数据和单选按钮并使用数据保存单选按钮的选定值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30936294/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com