Welcome Guest, Not a member yet? Register   Sign In
SQL Join
#3

[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


Messages In This Thread
SQL Join - by El Forum - 08-21-2008, 07:35 AM
SQL Join - by El Forum - 08-21-2008, 08:11 AM
SQL Join - by El Forum - 08-21-2008, 08:27 AM
SQL Join - by El Forum - 08-21-2008, 09:55 AM
SQL Join - by El Forum - 08-21-2008, 10:23 AM
SQL Join - by El Forum - 08-21-2008, 10:48 AM
SQL Join - by El Forum - 08-21-2008, 01:03 PM
SQL Join - by El Forum - 08-21-2008, 01:32 PM



Theme © iAndrew 2016 - Forum software by © MyBB