Query the database and display the content in arrays by conditions. how can this problem be solved? For website business reasons, the order content contains N different names & nbsp; mobile phone & nbsp; Gender & nbsp; and other information. when uploading a form, I uploaded the order in array mode. now I need to display a total order and sort the order number & nbsp; group each order. Do I have to query the output and display in array mode? Because the database is queried, the content is displayed in arrays by conditions. how can this problem be solved?
Because of the website business, the order content contains N different names, mobile phone gender, and so on. when uploading a form, it is uploaded in an array. now you need to display a total order, do I have to query the output and display of each order by order number? I am a newbie, so I would like to ask you here!
The database structure is as follows:
Id name shouji sex zhuangtai orderid
1 Zhang San 138XXX male 1 1
2 Li Si 186XXX female 1 1
3 Wang Wu 172XXX male 1 1
4 Xiaobao 189XXX male 1 2
5 Shao Zhuang 186XXX male 1 2
6 sweet 133XXX female 2 3
7 Dabao xxx male 3 4
......................
As you can see, all the data is stored in the database according to this structure. each order number only has the same orderid field, and others are different!
Now, you need to output these orders on a page and display them as follows. what should I do? Could you write a method and example? Thank you!
Database array query
------ Solution --------------------
You can write it like this.
$ R = mysql_query ('select orderid, zhuangtai, group_concat ('name') as name, group_concat ('shouji ') as shouji, group_concat ('sex ') as sex from 'order' group by orderid ');
Echo"
";
Echo"NameMobile phoneGender";
While ($ row = mysql_fetch_assoc ($ r )){
$ Shouji_arr = explode (',', $ row ['shouji ']);
$ Sex_arr = explode (',', $ row ['sex']);
Echo"
Order Number: ". $ row [orderid]." status: ". $ row ['zhuangtai']."";