看板 PHP 關於我們 聯絡資訊
基本上我因為快要出門還沒時間去結構化你的程式。 至少先簡化一些。 有空我研究再把他結構化掉。 <?php //--------------資料庫連結 這一段是必要的,為何不另外寫成一引述函式檔? //--------------計算內部幾筆資料 //$count_get = mysql_query("SELECT COUNT(*) FROM iftep_qtype "); //$counts = mysql_fetch_array($count_get); ↑remark這二行,保留他只是跟你說他用不到。 //--------------抓取資料庫每一筆資料 $tmp_dbqtype = mysql_query(" SELECT * FROM iftep_qtype "); while($_dbqtype = mysql_fetch_array($tmp_dbqtype)){ //--------------抓取資料庫資料 if(!empty($_dbqtype)){ $html .='<tr>'; for($j=0;$j<=2;$j++){ $html .='<td >'.$_dbqtype[$j].'</td>'; } $html .='</tr>'; }else{ print "&nbsp"; } } mysql_close($LINK); ?> 另外,如果你是全陣列的資料都抓都要印的話: 要把mysql_fetch_array改成mysql_fetch_assoc 並且把for(j=0;j<2;j++){}改成: foreach($_dbqtype as $value){ $html .= '<td>$value</td>'; } -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 59.104.131.233 ※ 編輯: tkdmaf 來自: 59.104.131.233 (12/25 12:24)
CAnthony15:謝謝!!  資料可以正常讀出  12/25 14:01