我想從兩個表細節我database.I使用下面的代碼獲取使用兩個表
$sqlall="SELECT
student_detail.reg_no
, student_detail.full_Name
, student_detail.year_of_study
, student_detail.faculty
, student_detail.course
,student_hostel.reg_no
,student_hostel.room_no
,student_hostel.hostel_id
FROM student_detail,student_hostel
WHERE student_detail.reg_no = student_hostel.reg_no; ";
//This is print part
$result = $conn->query($sqlall);
if ($result->num_rows > 0) {
// output data of each row
//create table
echo "<table class=\"table table-hover\">
<tr>
<th>Reg. No.</th><th>Hostel id</th><th>Room No</th></tr>";
while($row = $result->fetch_assoc()) {
echo"<tr id=\"".$row["student_detail.reg_no"]."\" onclick=\"Redirect(this.id)\"><td>".$row["student_detail.reg_no"]."</td><td>".$row["student_hostel.room_no"]."</td><td>".$row["student_hostel.room_no"]."</td></tr>";
}
echo "</table>";
}
else
{
echo "<table class=\"table table-hover\">
<tr>
<th>Reg. No.</th><th>Hostel id</th><th>Room No</th></tr>;
<span id></span>
</table>";
}
一個查詢會得到數據後,然後出現錯誤
公告:未定義指數:student_detail.reg_no在C:\ XAMPP \ htdocs中\ HMS \ HMS \ LIB \ HOS_current.php上線47
我怎樣才能解決呢?
你將有權發佈比則 –
請只是呼應了行不表名'回聲$行更多[ 'reg_no'];' –
當你運行查詢和你如何顯示它時,用代碼編輯問題 –