PHP generates table instance code

Source: Internet
Author: User
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.

  1. $ Link = mysql_connect ("localhost", "root", "123456 ");
  2. $ Db = mysql_select_db ("bustest", $ link );
  3. $ Sql1 = "select name from info group by name order by id asc ";
  4. Print ("
  5. $ Res1 = mysql_query ($ sql1 );
  6. While ($ row1 = mysql_fetch_array ($ res1 )){
  7. $ Name = $ row1 ["name"];
  8. $ Sql2 = "select id from info where name = $ name order by id asc ";
  9. $ Res2 = mysql_query ($ sql2 );
  10. While ($ row2 = mysql_fetch_array ($ res2 )){
  11. Print ("
  12. $ Id = $ row2 ["id"];
  13. Print ("
  14. $ Sql3 = "select count (*), id from info where name = $ name group by name order by id asc ";
  15. $ Res3 = mysql_query ($ sql3 );
  16. While ($ row3 = mysql_fetch_array ($ res3 )){
  17. $ Id1 = $ row3 ["id"];
  18. If ($ id1 = $ id ){
  19. $ Num = $ row3 [0];
  20. Print ("
  21. } Else {
  22. Print ("
  23. }
  24. }
  25. }
  26. Print ("");
  27. }
  28. Print ("
  29. "); "); "); "); ");
    $ Id");
  30. Print $ name;
  31. Print ("
  32. ");
  33. Mysql_close ($ link );
  34. ?>

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.