Php output table implementation code (revised version) _ PHP Tutorial-php Tutorial

Source: Internet
Author: User
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' '. "\ R \ n ";} Else {Echo' '. "\ R \ n ";}}Else {Echo' '. "\ R \ n ";}$ K + = 1; // auto-increment}?>
'. $ K .'
'. $ K .'
'. $ K .'




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. ="";
}
}
?>




Echo $ 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...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.