Php loop output how to achieve the same value under a field only output one data table at a time student Field is id name age
There are 1, 3, and 18 values in the field.
2 Li Si 17
3 Wang Wu 18
4 Li Si 17
I want to output a table cyclically in php
However, the name of Li Si is output only once.
To achieve this
Name age
Zhang San 18
Name age
Li Si 17
Li Si 17
Name age
Wang Wu 18
$ SQL = mysql_query ('select distinct name from student ');
While ($ row = mysql_fetch_array ($ SQL )){
}
If $ row ['age'] cannot be written in this way, how to implement php? thank you!
Reply to discussion (solution)
$ SQL = mysql_query ('select distinct name, age from student ');
Select distinct name from student
Change
Select distinct name, age from student
$ SQL = mysql_query ('select distinct name, age from student ');
Are there other methods?
Select distinct name from student
Change
Select distinct name, age from student
This method does not work
Select *, count (distinct name) from student group by name can be implemented, but thank you.