我有两张桌子
学生
S_ID, LastName, FirstName, MiddleName
takensubject
S_ID, SubjectCode, Time
我在下面有一个代码,使用session来显示从takensubject获取Subject但是它只显示ID我想要的是显示使用来自takensubject的ID的学生的全名我的代码下面显示了一些错误警告:mysqli_num_rows()期望参数1是mysqli_result,boolean。 任何人都可以帮我纠正我的疑问吗?
<?php
include'database.php';
$sescode = $_SESSION['sessioncode'];
$sestime = $_SESSION['sessiontime'];
$conn = mysqli_connect($server, $dbusername, $dbpassword, $database);
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
$sql = "SELECT * FROM takensubject tb2, student tb1 where tb2.S_ID=tb1.S_ID and SchoolYear ='$Sy' and Semester ='$Sem' and SubjectCode='$sescode' and Time='$sestime'";
$no = 0;
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) > 0) {
while ($row = mysqli_fetch_assoc($result)) {
$no++;
echo"<td>$no ).</td> ";
echo"{$row['S_ID']}";
echo"{$row['LastName']}<br>";
}
} else {
echo "No Record Results";
}
mysqli_close($conn);
?>
它会继续显示此警告:
mysqli_num_rows()期望参数1为mysqli_result,boolean
答案 0 :(得分:0)
我没有在你的任何表中看到SchoolYear,Semester列。你还需要在列名旁边指定表,如tb2.Time。同样回应您的查询并直接在phpmyadmin中尝试检查错误。 希望它有所帮助:)尝试像
这样的东西SELECT takensubject.*,student.* FROM takensubject INNER JOIN student ON takensubject.S_ID=student.S_ID where takensubject.SchoolYear ='$Sy' and takensubject.Semester ='$Sem' and takensubject.SubjectCode='$sescode' and takensubject.Time='$sestime'
答案 1 :(得分:0)
我猜您的查询正在返回dispatch_async
。尝试这样的事情。
FALSE