I have a problem on output the MySQL result to HTML. I had a MySQL result which returns:
| title | category_name | from_where |
---------------------------------------------
| Title num 1 | Journal | iidl_file |
---------------------------------------------
| Title num 2 | Books | iidl_file |
---------------------------------------------
| Title num 3 | Announcement | iidl_post |
---------------------------------------------
| Title num 4 | News | iidl_post |
---------------------------------------------
How can I preview this data in HTML like this:
iidl_file
- Title num 1 (Journal)
- Title num 2 (Books)
--------------------------
iid_post
- Title num 3 (Announcement)
- Title num 4 (News)
This is what I would do:
If you have many records, you will benefit greatly from making sure there is an index on the
from_wherecolumn.Here is some pseudo-code:
Now your
$groupswill contain arrays keyed by thefrom_wherecolumn.Doing this, you actually don’t have to even issue the ORDER BY in the query.