How to implement category headings, which show some field content on the category

Source: Internet
Author: User
How to implement a category to do a title, below the title shows some field content under that category
It should be done with nested loops, but I've cycled a couple of times and it's all wrong, and it could be that the outer loop and the inner loop are repeating:

PHP Code
  $result = mysql_query ("Select P_class from product group by P_class limit 40");//Get Product category name: P_class Mysql_data_seek ($result      , 0); while ($row =mysql_fetch_row ($result)) {echo "
  
   ';        echo "$row [$i]";     Echo ';        $result 2 = mysql_query ("select * from Product where p_class= $row [$i] Limit 0,4"); while ($row =mysql_fetch_row ($result 2)) {echo '
  
  
  
   
   \ n "; echo "
   
   
      \ n "; for ($i =0; $i 
    
'; for ($i =0; $i < td="">
'; }//outer Loop End} echo "\ n "; } echo "\ n "; mysql_free_result ($result); Mysql_close ($conn);? >




------Solution--------------------
There is no mistake in thinking, the code is basically correct
But there's something wrong with your HTML code.
Your inner table, written outside the outer table marker, naturally looks like a mess.
------Solution--------------------
For reference only:
SQL code
mysql> select * from csdn_test4;+----+--------+--- -------------------+| ID | Type |  Content |+----+--------+----------------------+| 1 | Astronomy |  Astronomical Astronomical Astronomy | | 2 | Astronomy |  Daily Astronomy | | 3 | Astronomy |  Wen Tian Astronomy | | 4 | Geography |  Geographical Geographic Geography | | 5 | Geography |  Ground to Ground | | 6 | Geography |  Taken Care | | 7 | Technology |  Science and Technology Technology | | 8 | Technology |  Cococo | | 9 | Technology | Technical and technical |+----+--------+----------------------+9 rows in Set (0.00 sec) 
------Solution--------------------
Discussion
Thank you so much.
But I really do not understand, because there are many changes to the layout, such as the number of fields in my data table is a lot, this page needs to display the knowledge of two or three fields. I don't know how to change it.
  • 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.