Php output table implementation code (revised version ). Many of the code on the Internet is incorrect. The code for copying the code is as follows: there are a total of 10 data titleheadbodytablewidth8 online codes in the 5 columns of htmlheadtitle in two rows. many of them are incorrect, and the script house has fixed them.
The code is as follows:
Two rows, five columns, a total of 10 data records
$ Num = 5; // The number of columns displayed in each row$ K = 1; // InitializationWhile ($ k <= 10){If ($ k % $ num = 0 ){If ($ k = 10 ){Echo'
| '. $ K .' |
'. "\ R \ n ";} Else {Echo'
| '. $ K .' |
'. "\ R \ n ";}}Else {Echo'
| '. $ K .' | '. "\ R \ n ";}$ K + = 1; // auto-increment}?>
The following is what is read from the database:
The code is as follows:
$ SQL = "select * from table ";
$ Query = mysql_query ($ SQL );
$ Num = mysql_num_rows ($ query );
For ($ I = 0; $ I <$ num; $ I ++ ){
$ Result = mysql_fetch_array ($ query );
If ($ I % 3 = 0 ){
$ Str. ="";
}
$ Str. ="". $ Result [" title "]."";
If ($ I + 1) % $ num = 0 ){
$ Str. ="";
}
}
?>
Bytes. The code is as follows: html head title contains 10 data records in five columns in two rows/title/head body table border = "1" width = 8...