Jump to content


Photo

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


  • Please log in to reply
10 replies to this topic

#1 techiefreak05

techiefreak05
  • Members
  • PipPipPip
  • Advanced Member
  • 494 posts
  • LocationER, MN

Posted 05 August 2006 - 08:16 AM

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??
Link shortener with advanced, detailed statistics:

http://tyny.us/

#2 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 05 August 2006 - 08:44 AM

Are you talking about within your site only?

#3 ronverdonk

ronverdonk
  • Members
  • PipPipPip
  • Advanced Member
  • 277 posts
  • LocationNetherlands

Posted 05 August 2006 - 09:12 AM

You are not talking about adding a link to your site into your visitor's Favorites list of their browser, are you?

RTFM is an almost extinct art form, it should be subsidized.

#4 techiefreak05

techiefreak05
  • Members
  • PipPipPip
  • Advanced Member
  • 494 posts
  • LocationER, MN

Posted 05 August 2006 - 09:14 AM

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"
Link shortener with advanced, detailed statistics:

http://tyny.us/

#5 techiefreak05

techiefreak05
  • Members
  • PipPipPip
  • Advanced Member
  • 494 posts
  • LocationER, MN

Posted 05 August 2006 - 10:16 AM

..anybody know how to accomplish this?
Link shortener with advanced, detailed statistics:

http://tyny.us/

#6 ignace

ignace
  • Moderators
  • Now mod flavored
  • 6,431 posts
  • LocationBelgium

Posted 05 August 2006 - 10:20 AM

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!

#7 techiefreak05

techiefreak05
  • Members
  • PipPipPip
  • Advanced Member
  • 494 posts
  • LocationER, MN

Posted 05 August 2006 - 10:25 AM

How can I do that ... ? and especially how do i add the current URL into the database??
Link shortener with advanced, detailed statistics:

http://tyny.us/

#8 ronverdonk

ronverdonk
  • Members
  • PipPipPip
  • Advanced Member
  • 277 posts
  • LocationNetherlands

Posted 05 August 2006 - 10:40 AM

Create column url in your db, construct your URL of the current page:

$url = "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];

$sql="UPDATE yourtable SET url=$url WHERE ....."


RTFM is an almost extinct art form, it should be subsidized.

#9 GingerRobot

GingerRobot
  • Staff Alumni
  • Advanced Member
  • 4,086 posts
  • LocationUK

Posted 05 August 2006 - 10:46 AM

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:
<?php
$url = "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
$sql="INSERT INTO yourtable SET url='$url',name='$user'";
mysql_query($sql);
?>

And then to generate all of their favourites:
<?php
$sql = "SELECT * FROM yourtable WHERE user='$user'";
$result = mysql_query($sql);
while($row = mysql_fetch_assoc($result)){
echo $row['url'];
echo "<br />";
}
?>

Of course, i expect you'd want to modify the output to make it look a bit nicer, but thats the general idea.

#10 ignace

ignace
  • Moderators
  • Now mod flavored
  • 6,431 posts
  • LocationBelgium

Posted 05 August 2006 - 10:48 AM

ron, don't you mean INSERT? How can you update if the page does not already exists? Thus something like:

$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');";


#11 ronverdonk

ronverdonk
  • Members
  • PipPipPip
  • Advanced Member
  • 277 posts
  • LocationNetherlands

Posted 05 August 2006 - 10:53 AM

Sorry, of course I mean the INSERT (I was actually doing some parallel work on an UPDATE stmt).
RTFM is an almost extinct art form, it should be subsidized.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users