ams53 Posted December 28, 2007 Share Posted December 28, 2007 I'm pretty new to php/mysql. Is it possible to write a script where the user stores internal links to other parts of the website under a "my favorites" section. I need to allow the user to click on a link (i.e. "add to my favorites") next to a product and have an internal link added to that specific users profile under a "my favorites" tab. I've thought about cookies but the user should be able to access these preferences from any computer. Does anyone have any suggestions? Any scripts out there for this? Please teach this newbie a thing or two. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/83524-storing-user-preferences/ Share on other sites More sharing options...
revraz Posted December 28, 2007 Share Posted December 28, 2007 Have access to a database? Quote Link to comment https://forums.phpfreaks.com/topic/83524-storing-user-preferences/#findComment-424952 Share on other sites More sharing options...
ams53 Posted December 28, 2007 Author Share Posted December 28, 2007 Yeah, I'm using a mysql database for the site. Quote Link to comment https://forums.phpfreaks.com/topic/83524-storing-user-preferences/#findComment-424953 Share on other sites More sharing options...
p2grace Posted December 28, 2007 Share Posted December 28, 2007 Have a db table that tracks favorites along with the user id. When they click "Add to Favorites" it'll create an insert statement adding that item the favorites table with the user's id. Quote Link to comment https://forums.phpfreaks.com/topic/83524-storing-user-preferences/#findComment-424958 Share on other sites More sharing options...
ams53 Posted December 29, 2007 Author Share Posted December 29, 2007 Have a db table that tracks favorites along with the user id. When they click "Add to Favorites" it'll create an insert statement adding that item the favorites table with the user's id. In this new table, is a new record inserted or a new field created in the table? If only a record, then do I need a specific number of fields or can I allow an unlimited number of "favorites"? Quote Link to comment https://forums.phpfreaks.com/topic/83524-storing-user-preferences/#findComment-424960 Share on other sites More sharing options...
p2grace Posted December 29, 2007 Share Posted December 29, 2007 A new record is inserted, but since you're tracking it by the user id, you can have an unlimited number of favorites. Table should look like this: favorites fid* (int) uid (int) pid (int) timestamp (timestamp) Where: fid = favorite id, will be the primary key uid = user id pid = page id Quote Link to comment https://forums.phpfreaks.com/topic/83524-storing-user-preferences/#findComment-424964 Share on other sites More sharing options...
ams53 Posted December 29, 2007 Author Share Posted December 29, 2007 It seems simple enough. Thanks for the help. Quote Link to comment https://forums.phpfreaks.com/topic/83524-storing-user-preferences/#findComment-424965 Share on other sites More sharing options...
p2grace Posted December 29, 2007 Share Posted December 29, 2007 No problem, if it works don't forget to click "Topic Solved" Quote Link to comment https://forums.phpfreaks.com/topic/83524-storing-user-preferences/#findComment-424966 Share on other sites More sharing options...
revraz Posted December 29, 2007 Share Posted December 29, 2007 You could also just add a field to the existing user table, and use a delimeter to seperate the favorites. Quote Link to comment https://forums.phpfreaks.com/topic/83524-storing-user-preferences/#findComment-424967 Share on other sites More sharing options...
trq Posted December 29, 2007 Share Posted December 29, 2007 You could also just add a field to the existing user table, and use a delimeter to seperate the favorites. But that would be poor design. Quote Link to comment https://forums.phpfreaks.com/topic/83524-storing-user-preferences/#findComment-424981 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.