Php + mysql output question Field 1 field 2
Big classification 1 small classification 1
Big classification 1 small Classification 2
How can I use php + mysql to output the following content for the above database tables?
Big classification 1
Small Category 1
Sub-category 2
Reply to discussion (solution)
This post was last edited by ss86965921ss at 19:30:05
Field 1 field 2
Big classification 1 small classification 1
Big classification 1 small Classification 2
How can I use php + mysql to output the following content for the above database tables?
Big classification 1
Small Category 1
Sub-category 2
......
// The first is MYSQL Query. Only SQL statements are written here.
$ SQL = "select field 1, field 2 from table name where condition ";
$ Result = $ mysqli-> query ($ SQL );
// Obtain the matching records and assign them to a variable.
$ Rs1 = $ result-> fetch_assoc ();
$ Rs2 = $ result-> fetch_assoc ();
// Then output
Echo"
". $ Rs1 ['Field 1']."
". $ Rs1 ['Field 2']."
". $ Rs2 ['Field 2']."
";
How do I output big Classification 2?
How do I output big Classification 2?
Big classification 1
Small Category 1
Sub-category 2
Big Classification 2
Small Category 1
Sub-category 2
The method on the second floor is not feasible. if it is to be added later, it cannot be generated.
$ Rs = mysql_query ('select * from table order by 1, 2'); $ last = ''; echo''; Where ($ r = mysql_fetch ($ rs) {if ($ r ['Field 1']! = $ Last) {echo"
{$ R ['Field 1']}
"; $ Last = $ r ['Field 1'];} echo"{$ R ['Field 2']}
";}
I don't feel wrong.