我試圖在已使用echo current
和echo next
從SQL查詢填充的會話變量中輸出結果。但是沒有文字回顯到屏幕。在會話中顯示下一條記錄php數組
用於獲取數據並投入陣列 $SQL = "Select * from Property_Features WHERE pf_pr_ID = 3"; $result = $conn->query($SQL); $_SESSION[arrProperty_Features] = $result->fetch_assoc();
嘗試呼應第一項目陣列(電流)
<p><input class="w3-input" name="txtFeature1" type="text" id="txtFeature1" value="<?php echo current ($_SESSION[arrProperty_Features][pf_Feature]);?>"><br>
嘗試在陣列呼應第二項SQL語句(下)
<p><input class="w3-input" name="txtFeature2" type="text" id="txtFeature2" value="<?php echo next ($_SESSION[arrProperty_Features][pf_Feature]);?>"><br>
「$ result-> fetch_assoc()」不會一次給你所有的結果。繼續迭代它,直到它給你null – Tarun
謝謝塔倫 - 我試過這個,但它似乎被困在一個永恆的循環中 while($ result = $ conn-> query($ SQL)){ \t $ _SESSION [arrProperty_Features] = $ result-> fetch_assoc(); } –