gpt4 book ai didi

php - 此代码没有从学生表中获取数据

转载 作者:行者123 更新时间:2023-11-29 23:33:37 25 4
gpt4 key购买 nike

我有两个表,student 和 Stusub,
学生有 snamesuni_roll_no
stusub 具有 suni_roll_nosub_code
我请求 sub_code 并且此代码未显示数据库的结果,

<?php
include("db.php");

$sub_code =$_REQUEST['sub_code'];

$query = @mysql_query("SELECT student.sname, student.sroll_no
FROM student INNER JOIN stusub
ON student.suni_roll_no=stusub.suni_roll_no where sub_code = '$sub_code';");
while($test = @mysql_fetch_array($query))
{
$sub_code = $test['sub_code'];
echo "<tr align='center'>";

echo"<td><font color='black'>" .$test['sname']."</font></td>";
echo"<td><font color='black'>" .$test['sroll_no']."</font></td>";


echo "</tr>";
}
mysql_close($conn);
?>

最佳答案

不应放入查询内;

try it

<?php
include("db.php");

$sub_code =$_REQUEST['sub_code'];

$query =mysql_query("SELECT student.sname, student.sroll_no
FROM student INNER JOIN stusub
ON student.suni_roll_no=stusub.suni_roll_no where sub_code = '$sub_code'");
while($test =mysql_fetch_array($query))
{
$sub_code = $test['sub_code'];
echo "<tr align='center'>";

echo"<td><font color='black'>" .$test['sname']."</font></td>";
echo"<td><font color='black'>" .$test['sroll_no']."</font></td>";


echo "</tr>";
}
mysql_close($conn);
?>

关于php - 此代码没有从学生表中获取数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26461168/

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