techiefreak05 Posted August 5, 2006 Share Posted August 5, 2006 Hi, when my users see a profile page.. or a page in general that they want to view on a regular basis.. i want them to be able to click something that adds the current page toa "list" that displays on their homepage. is that posible??? and HOW?? Quote Link to comment https://forums.phpfreaks.com/topic/16620-add-page-to-fav-list-is-it-simple/ Share on other sites More sharing options...
trq Posted August 5, 2006 Share Posted August 5, 2006 Are you talking about within your site only? Quote Link to comment https://forums.phpfreaks.com/topic/16620-add-page-to-fav-list-is-it-simple/#findComment-69673 Share on other sites More sharing options...
ronverdonk Posted August 5, 2006 Share Posted August 5, 2006 You are not talking about adding a link to your site into your visitor's Favorites list of their browser, are you? Quote Link to comment https://forums.phpfreaks.com/topic/16620-add-page-to-fav-list-is-it-simple/#findComment-69681 Share on other sites More sharing options...
techiefreak05 Posted August 5, 2006 Author Share Posted August 5, 2006 THORPE: "yes"RONVERDONK: "no, a list of their favorite pages on my site, and all the pages they added will appear as links on their home page" Quote Link to comment https://forums.phpfreaks.com/topic/16620-add-page-to-fav-list-is-it-simple/#findComment-69682 Share on other sites More sharing options...
techiefreak05 Posted August 5, 2006 Author Share Posted August 5, 2006 ..anybody know how to accomplish this? Quote Link to comment https://forums.phpfreaks.com/topic/16620-add-page-to-fav-list-is-it-simple/#findComment-69711 Share on other sites More sharing options...
ignace Posted August 5, 2006 Share Posted August 5, 2006 the database is your friend, just create a datbase named favorites or something and then when a user clicks the 'Add to favorites' it inserts the current page(path), his userid(need this to load it on his profile/homepage page) to the database, and on his profile page you just start rollin' it out! Quote Link to comment https://forums.phpfreaks.com/topic/16620-add-page-to-fav-list-is-it-simple/#findComment-69712 Share on other sites More sharing options...
techiefreak05 Posted August 5, 2006 Author Share Posted August 5, 2006 How can I do that ... ? and especially how do i add the current URL into the database?? Quote Link to comment https://forums.phpfreaks.com/topic/16620-add-page-to-fav-list-is-it-simple/#findComment-69713 Share on other sites More sharing options...
ronverdonk Posted August 5, 2006 Share Posted August 5, 2006 Create column url in your db, construct your URL of the current page:[code]$url = "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];$sql="UPDATE yourtable SET url=$url WHERE ....."[/code] Quote Link to comment https://forums.phpfreaks.com/topic/16620-add-page-to-fav-list-is-it-simple/#findComment-69724 Share on other sites More sharing options...
GingerRobot Posted August 5, 2006 Share Posted August 5, 2006 I would suggest that you'd be using INSERT statements rather than UPDATES...assuming you have a table in your datbase with a user field and a url field, to add a favourite:[code]<?php$url = "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];$sql="INSERT INTO yourtable SET url='$url',name='$user'";mysql_query($sql);?>[/code]And then to generate all of their favourites:[code]<?php$sql = "SELECT * FROM yourtable WHERE user='$user'";$result = mysql_query($sql);while($row = mysql_fetch_assoc($result)){echo $row['url'];echo "<br />";}?>[/code]Of course, i expect you'd want to modify the output to make it look a bit nicer, but thats the general idea. Quote Link to comment https://forums.phpfreaks.com/topic/16620-add-page-to-fav-list-is-it-simple/#findComment-69726 Share on other sites More sharing options...
ignace Posted August 5, 2006 Share Posted August 5, 2006 ron, don't you mean INSERT? How can you update if the page does not already exists? Thus something like:[code]$Userid = $_SESSION['userid']; // or something..$Url = eval("http://" . $_SERVER['HTTP_POST'] . $_SERVER['PHP_SELF']);// Does php_self also includes queries? if not add . $_SERVER['QUERY_STRING'];$Sql = "INSERT INTO `favorites` (`Url`, `User_id`) VALUES ('$Url', '$Userid');";[/code] Quote Link to comment https://forums.phpfreaks.com/topic/16620-add-page-to-fav-list-is-it-simple/#findComment-69727 Share on other sites More sharing options...
ronverdonk Posted August 5, 2006 Share Posted August 5, 2006 Sorry, of course I mean the INSERT (I was actually doing some parallel work on an UPDATE stmt). Quote Link to comment https://forums.phpfreaks.com/topic/16620-add-page-to-fav-list-is-it-simple/#findComment-69730 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.