Jump to content

Archived

This topic is now archived and is closed to further replies.

techiefreak05

ADD Page to "fav" list?? is it simple??

Recommended Posts

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??

Share this post


Link to post
Share on other sites
Are you talking about within your site only?

Share this post


Link to post
Share on other sites
You are not talking about adding a link to your site into your visitor's Favorites list of their browser, are you?

Share this post


Link to post
Share on other sites
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"

Share this post


Link to post
Share on other sites
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!

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
Sorry, of course I mean the INSERT (I was actually doing some parallel work on an UPDATE stmt).

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.