Reputation: 11
I need help for each loop that I would like to find the data from mysqldbx with find if data have parent category first and grouping the data with them parent and echo them out with for each loop maybe it looks like this below :
start for each loop
show 5 category 5 ,this also all row (only category 5) ,finish if no data
<tr><td>row=id</td> <td>row=nama</td> <td>row=category1</td></tr>
<tr><td>row=id</td> <td>row=nama</td> <td>row=category2</td></tr>
<tr><td>row=id</td> <td>row=nama</td> <td>row=category5</td></tr>
end theforeach loop
Example data on table
id=1,name=data1,category=1
id=2, name=data2,category=1
id=3, name=data3,category=5
id=4, name=data4,category=2
id=5, name=data5,category=5
id=6, name=data6,category=2
Upvotes: 1
Views: 410
Reputation: 126
You can write SQL query
for this table and you can order by category,
i.e.
select * from your_table order by category
Then you have to do nothing with foreach loop
Upvotes: 1