我見過很多類似的問題但他們都混淆了我,因爲我沒有使用$ wpdb變量來獲取數據。我正在使用簡單的PHP方式來獲取數據通過調用wordpress數據庫。但不知何故,它只返回一行。這裏是用於獲取數據的代碼行。MySql只返回一行同時獲取數據表格wordpress
$sql = "SELECT * FROM teacher_directory";
if($result = mysqli_query($link, $sql)){
if(mysqli_num_rows($result) > 0){
echo "<table>";
echo "<tr>";
echo "<th>S. No.</th>";
echo "<th>Name</th>";
echo "<th>Designation</th>";
echo "<th>Department</th>";
echo "<th>Tele/Mob.No.</th>";
echo "</tr>";
while($row = mysqli_fetch_array($result)){
echo "<tr>";
echo "<td>" . $row['S. No.'] . "</td>";
echo "<td>" . $row['Name'] . "</td>";
echo "<td>" . $row['Designation'] . "</td>";
echo "<td>" . $row['Department'] . "</td>";
echo "<td>" . $row['Tele/Mob.No.'] . "</td>";
echo "</tr>";
}
echo "</table>";
任何幫助或建議將是可觀的。
你得到多個字段在實際查詢? – Milap
mysqli_num_rows($ result)的結果是什麼 –
我在輸出中得到了一個完整的單行。 – Rishabh