[eluser]iainco[/eluser]
Hi Randy, thanks for your post.
A user saves (or subscribes) to a feed by checking a box in the view. In terms of the database, if the user with ID 1 has saved the feed with ID 1 there will be a row in the `user_feed` table with userID = 1 and feedID = 1.
Feeds that users have not saved are still displayed in the view, but nothing is stored for them in the `user_feed` table, and the feeds the user has saved have their checkboxes ticked automatically.
I should add that, fetchFeed should return an array like this:
Array (
[0] Array (ID = 1, title = 'Feed 1', feedID = null) //user has not saved feed with ID 1
[1] Array (ID = 2, title = 'Feed 2', feedID = 2) // user has saved feed with ID 2
[2] Array (ID = 3, title = 'Feed 3', feedID = null) // user has not saved feed with ID 3
)
.. if there are only 3 feeds present in the feed table.
I can use this code so the correct checkboxes are checked automatically.
Code:
input type="checkbox" onclick="saveFeed(<?=$i['ID']?>)" <?=($i['feedID'] == $i['ID']) ? 'checked':''?>
Iain