I'm looking to generate an HTML table like below.
|nick_name| bookmarked_sites |
-------------------------------
| admin | http://test1.com |
| | http://test2.com |
| | http://test3.com |
-------------------------------
| John | http://mysite.com |
-------------------------------
I'm query the database using $wpdb and it's building an array of information which looks like this:
$userquery = $wpdb->get_results("SELECT * FROM bookmarks");
print_r($userquery);
Array (
[0] => stdClass Object (
[id] => 1 [user_id] => 1 [post_id] => 1654,1532,1672,1610,1676 )
[1] => stdClass Object (
[id] => 3 [user_id] => 6 [post_id] => 1680,1654 ) )
I started to build my first foreach
to extract the user_id
, then I had a nested foreach
to extract the post_id
for that user. But I'm realizing now that I can't easily build an HTML table off that concept.
I'm having a hard time conceptualizing the logic to put this all together.
Thanks!