Re: [請益] 請問一個有點困難的回圈問題

看板PHP作者 (大順)時間19年前 (2006/11/06 19:17), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串4/4 (看更多)
太感謝您拉 謝謝你這麼熱心的告訴我 我後來找到一個dreamweaver的extension 不過我竟然看不太懂的程式碼的意思 所以也不知道是怎樣解決的 它是這樣寫的(它主要的功能是可以讓找出來的資料作水平的排列N個之後在垂直排列M個) 可是我在當中竟然不知道如何去修改N跟M的個數,只能再要更改的時候去把程式碼刪掉 然後重新用一次EXTENSION XD有沒有好新人可以告訴我阿^^謝謝 -----------------------------程式碼分隔線------------------------------------ <?php $New_endRow = 0; $New_columns = 1; // number of columns $New_hloopRow1 = 0; // first row flag do { if($New_endRow == 0 && $New_hloopRow1++ != 0) echo "<tr>"; ?> <td><table > xxxxxxxxxxxxxxxxxx(table的部分有點繁雜我就去掉了 </table></td> <?php $New_endRow++; if($New_endRow >= $New_columns) { ?> </tr> <?php $New_endRow = 0; } } while ($row_New = mysql_fetch_assoc($New)); if($New_endRow != 0) { while ($New_endRow < $New_columns) { echo("<td>&nbsp;</td>"); $New_endRow++; } echo("</tr>"); }?> ※ 引述《layachang (這樣笑著很開心!!)》之銘言: : : ------------------------------------------------------------ : : |●1手機___________________________________________________| : : |●2皮包___________________________________________________| : : |●3XXXX___________________________________________________| : : |●4$$$$___________________________________________________| : : |●5EEEE___________________________________________________| : : |●6@@@@___________________________________________________| : : |●7%%%%___________________________________________________| : : ------------------------------------------------------------ : : |●1RRRRR___________________|●1TRTR_______________________| : : |●2DDDDD___________________|●2ERW________________________| : : |●3SD______________________|●3BT\________________________| : : |●4TR______________________|●4TRTE_______________________| : : ------------------------------------------------------------ : : |●1------------------------|●1FSDF-----------------------| : : |●2FEW---------------------|●2!@#!-----------------------| : : |●3#FA---------------------|●3ERE------------------------| : : ------------------------------------------------------------ : : |●1------------------------|●1FSDF-----------------------| : : |●2FEW---------------------|●2!@#!-----------------------| : : |●3#FA---------------------|●3ERE------------------------| : : ------------------------------------------------------------ : <? : $global_dbh = mysql_connect("localhost","root","") or : die("Couldn't connect with database\n"); : mysql_select_db("db_table", $global_dbh) or die("Couldn't select : database\n"); : //資料表1 = table1 (只列出前7項) : //資料表2 = table2 (只列出前4項) : //資料表3 = table3 (只列出前4項) : //資料表4 = table4 (只列出前3項) : //資料表5 = table5 (只列出前3項) : //資料表6 = table6 (只列出前3項) : //資料表7 = table7 (只列出前3項) : $tableinfo[0][0] = "table1; $tableinfo[0][1] = "7"; : $tableinfo[1][0] = "table2; $tableinfo[1][1] = "4"; : $tableinfo[2][0] = "table3; $tableinfo[2][1] = "4"; : $tableinfo[3][0] = "table4; $tableinfo[3][1] = "3"; : $tableinfo[4][0] = "table5; $tableinfo[4][1] = "3"; : $tableinfo[5][0] = "table6; $tableinfo[5][1] = "3"; : $tableinfo[6][0] = "table7; $tableinfo[6][1] = "3"; : for ($i=0;$i<sizeof($tableinfo);$i++) : { : $sql = "select * from ".$tableinfo[$i][0]." limit 0,".$tableinfo[$i][1]; : $res = mysql_query($sql); : $j=0; : while ( $row = @mysql_fetch_assoc($res) ) { : $list[$i][$j] = $row; : $j++; : } : @mysql_free_result($res); : } : // 這時候你要得資料會以二維陣列存在$list中 : ?> : <table> : <tr> : <td colspan=2> : <table> : <? : for($i=0;$i<sizeof($list[0]);$i++) : { : echo "<tr>"; : echo "<td>".($i+1)."</td>"; : echo "<td>".$list[0][$i]."</td>"; : echo "</tr>"; : } : ?> : </table> : </td> : </tr> : <tr> : <td> : <table> : <? : for($i=0;$i<sizeof($list[1]);$i++) : { : echo "<tr>"; : echo "<td>".($i+1)."</td>"; : echo "<td>".$list[1][$i]."</td>"; : echo "</tr>"; : } : 下面懶的寫了 不知道是不是你要的東西@@? -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 61.216.2.126
文章代碼(AID): #15JndbYl (PHP)
文章代碼(AID): #15JndbYl (PHP)