Forum Moderators: coopster

Message Too Old, No Replies

Creating an add to favorites list

         

tresmom5

11:24 am on Jan 11, 2005 (gmt 0)

10+ Year Member



This seamed like an easy enough project to take on, but I can't seem to figure out anything. I was planning to use php for this. I am a newbie when it comes to php. I basically want to make a site with a list of things that a person can add to their favorite list. There will be multiple pages. The multiple pages part is where I really get stumped. I have seen other sites do this by what looks like links, but I am still sort of confused as to what they are doing. You'll see the url followed by a? and then the variable. So they'll click on the link say it's <a href="urlwhatever.php?theirvariable">Add to my list</a> Now I just for the life of me can't figure out how this works or where to begin. If someone could point me in the right direction to tutorials or how to do this I would appreciate it.

Teresa

mincklerstraat

12:53 pm on Jan 11, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



What you're looking for would probably be best asked in the javascript forum, since adding bookmarks / favorites is something that the browser does; once you know what the javascript is that you need to add, of course, you can use PHP to output this javascript. A good starting point would be to google javascript bookmark favorite and see what you get.

tresmom5

1:13 pm on Jan 11, 2005 (gmt 0)

10+ Year Member



I am not trying to have them bookmark sites. I am trying to make a list of things they save. They will not actually be links they are saving, but a name list - their favorite names they like.

Don't know if that makes sense.

mincklerstraat

1:44 pm on Jan 11, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Ah yeah, got it. Like a site-local list of bookmarks, pages they like on your site that they can get back to from your site's user interface.

For each page, you'll want some kind of unique identifier. If you just have articles, and all articles have a unique id that fetches them out of your db, this is real easy - just make a script 'savetomyfavorites.php' and on each article, make a link <a href="savetomyfavorites.php?articleno=345">, or whatever that article number is. savetomyfavorites.php then adds the number 345 to a field called favorites somehow in your users table (if articleno indeed is an integer) - probably the easiest would be to use explode(',' $articleno) and implode() to convert back and forth from a comma-separated list to an array.

Things are trickier if you don't have an easy unique idenitifier - if you want to have favorite saving available for pages with lots of different url structures. Then you have to use your page address as that identifier - put it into a parameter (maybe url encoding it first) - savetomyfavorites.php then will have to do some fancy checking to make sure your users aren't trying to put bad stuff in your db. You'll urldecode it probably, maybe do a regex check, and maybe other checks, to make sure it's free of things like ../ or other tricky stuff, and then saving it will be a bit more complicated too since you'll probably need to have a whole separate table, with a userid field and a field for the favorites, a new row for each entry.

webberme2

6:51 pm on Jan 28, 2005 (gmt 0)



tresmom5,

Did you ever figure out how to do this? I've been searching for something like this for a week and have had no luck.