The following code is used to generate a table instance in PHP, which is post after the program home test runs normally on this site. & Lt ;? Php $ linkmysql_connect (localhost, root, 123456); $ dbmysql_select_db (bustest, $ link); $ sql1selectnamefrominfogroupbynameorderbyi the code below PHP generates a table instance, after testing the normal operation of this site's programming House, it was posted.
-
- $ Link = mysql_connect ("localhost", "root", "123456 ");
- $ Db = mysql_select_db ("bustest", $ link );
- $ Sql1 = "select name from info group by name order by id asc ";
- Print ("
- $ Res1 = mysql_query ($ sql1 );
- While ($ row1 = mysql_fetch_array ($ res1 )){
- $ Name = $ row1 ["name"];
- $ Sql2 = "select id from info where name = $ name order by id asc ";
- $ Res2 = mysql_query ($ sql2 );
- While ($ row2 = mysql_fetch_array ($ res2 )){
- Print ("
- $ Id = $ row2 ["id"];
- Print ("
- $ Sql3 = "select count (*), id from info where name = $ name group by name order by id asc ";
- $ Res3 = mysql_query ($ sql3 );
- While ($ row3 = mysql_fetch_array ($ res3 )){
- $ Id1 = $ row3 ["id"];
- If ($ id1 = $ id ){
- $ Num = $ row3 [0];
- Print ("
- } Else {
- Print ("
- }
- }
- }
- Print ("");
- }
- Print ("
");
");
$ Id | ");
");- Print $ name;
- Print ("
| ");
");
");
- Mysql_close ($ link );
- ?>