Re: [請益] mysql_fetch_row 的問題

看板PHP作者 (愁痕飄絮)時間15年前 (2009/02/25 00:40), 編輯推噓1(100)
留言1則, 1人參與, 最新討論串2/2 (看更多)
※ 引述《freehand1122 (免費的最貴)》之銘言: : <? : ... : while ($row = mysql_fetch_row($result)) : { : echo "<TR>"; : for($i = 0; $i < mysql_num_fields($result); $i++) : { : echo "<TD>" . $row[$i] . "</TD>"; : } : echo "</TR>"; : } : ... : ?> : 這段是用巢狀迴圈來顯示所有紀錄內容 for迴圈我知道是顯示欄位內容 : while迴圈看書上是寫說用來顯示每一筆紀錄 顯示完後迴圈結束 : 但是我不曉得為什麼要這樣用 : 為什麼 $row = NULL 等式就不成立呢? : 因為不太懂電腦的邏輯 所以來問看看 : 請求各位高手幫忙解惑 <(_ _)> 你從哪看/聽到 mysql_fetch_row() 會回傳 NULL 的? 根據http://tw.php.net/mysql_fetch_row Return Values Returns an numerical array of strings that corresponds to the fetched row, or FALSE if there are no more rows. mysql_fetch_row() fetches one row of data from the result associated with the specified result identifier. The row is returned as an array. Each result column is stored in an array offset, starting at offset 0. 如果所有記錄都提取過了,那麼再呼叫mysql_fetch_row($ersult) 時,會回傳 FALSE 所以 $row 內容就變成 FALSE了,自然不成立 while 迴圈條件。 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 122.117.213.48

02/25 08:31, , 1F
了解了 看來是我自己會錯意 謝謝QQ
02/25 08:31, 1F
文章代碼(AID): #19f2CCH2 (PHP)
文章代碼(AID): #19f2CCH2 (PHP)