Page 1 of 1
This has been bugging me for... ooh... AGES!! lol
Posted: Tue Jun 16, 2009 1:04 pm
by ATMarsden
Hi all,
Nice to find a PHP forum, for queries... hope you are very helpful...
I was wondering how to create like a "feed" of users' recent activities...
If you don't know what i mean, this is an example of what comes out from a similar kinda thing (taken from Brimmies Super Cups on Facebook):
Congrats, Facebook User for rolling up a Donut (Long John) 13 minutes and 35 seconds ago
Congrats, Facebook User for rolling up a Sorbet 21 minutes and 21 seconds ago
Congrats, Facebook User for rolling up a 10 Oz Brimmium Bar 24 minutes and 20 seconds ago
Congrats, Facebook User for rolling up a Donut (Long John) 56 minutes and 0 seconds ago
Congrats, Facebook User for rolling up an Ice Capp 1 hour 3 minutes and 41 seconds ago
Was wondering how on earth they logged this to a file...
I have PHP and an SQL database, with a good capacity to implement virtually anything, so any suggestions are welcome...
Thank you all,
-Andrew Marsden-
PnM Apps.
Re: This has been bugging me for... ooh... AGES!! lol
Posted: Tue Jun 16, 2009 1:21 pm
by Eric!
I'm sure whatever scripts/games generate donut/sorbet activites just dump the results to a database or a file. The when a user "rolls up a donut" (WTF?) it just records that along with the time. Then scripts for other users can refresh the latest activity by going into the database and dumping out the log.
It would be easy for all user activites to be tracked that way by just logging everything you want to announce into a database.
Re: This has been bugging me for... ooh... AGES!! lol
Posted: Wed Jun 17, 2009 12:34 pm
by ATMarsden
Yes, but the actual question was requesting how to do that...
I don't know how to "dump to a database" or what have you...
Re: This has been bugging me for... ooh... AGES!! lol
Posted: Wed Jun 17, 2009 12:54 pm
by Eric!
I don't know facebook lingo. Are these online games users have written that interface with a status prompt telling them so and so rolled a donut? Or are these games/tools/whatever products of facebook developers?
If they are things facebook users are writing and facebook lets people share, then you might have a chance at learning how to do it from some who writes them for facebook. If these are internal php scripts written by facebook developers then they are not going to give you access to their database.
If you're asking how to have multiple users on your own site run php scripts that posts status results to others then you have a bigger learning curve.
Which is the case?
Re: This has been bugging me for... ooh... AGES!! lol
Posted: Wed Jun 17, 2009 1:13 pm
by ATMarsden
I was just looking, putting it simply, for a way that is like this, i already have to codes for everything else for this system, but don't know how to log it if they win certain items.. the facebook thing is beside the point, as it works directly from my own site.
Example:
Code: Select all
if (user wins carrot)
{
////Tell user
echo "carrot has been won";
////log user's winning
////(code for logging, mock up)
log $Userid " won a carrot at " $time ". Congrats!!!";
}
And then on Home page, it recalls:
(Person) won a carrot at 14:58:28.
or whatever... hope this is clear enough... but i find it hard to explain
-Andrew-
EDIT: This has nothing to do specifically with the facebook platform, because it is based upon my own site.
Re: This has been bugging me for... ooh... AGES!! lol
Posted: Wed Jun 17, 2009 5:07 pm
by Eric!
You need mysql installed and php. When your carrot awarding script identifies a winning user, pass that user's name and the prize to the following function.
You will need to setup a mysql database, account, and password. If you don't know how to do this, consult PHP and MYSQL for Dummies, despite the title it is a good book.
This function will insert into a table called EVENT the user, the time and the prize they won. The table EVENT has fields 'user','date','prize'.
Code: Select all
function store($user,$prize) //put the event in the database
{
$today = date("Y-m-d h:i:s"); // record time and date of event, you can customize this format to whatever.
$host="localhost";
$user="YOURACCOUNT";
$password="YOURPASSWORD";
$database="YOURDATABASE";
$connection = mysql_connect($host, $user,$password)
or die ("Couldn't connect to server.");
$db = mysql_select_db($database, $connection)
or die ("Couldn't select the database.");
$query = "INSERT INTO EVENT (user,date,prize) VALUES ('$user',$today','$prize')";
$result = mysql_query($query) or die ("<br>Couldn't execute query. ".mysql_error()."<br>".$query);
}
I have to take off now, but the next part would be to add a function that would look into the database history for the past 30 minutes or whatever timeframe you want your users to see for the past history. It would pull out the user name, the time and the prize and tell them whoever just ran your php script that called this announce function what happened.
Re: This has been bugging me for... ooh... AGES!! lol
Posted: Wed Jun 24, 2009 1:46 pm
by ATMarsden
Thank you,
Sorry, i forgot to log in and check on this again, as our servers crashed, so i was up to here ^ in work.
The point of this one was to check for the last x entries into the DB, rather than a specific time-frame, however I'm sure i could figure it out myself too ...
If you could just give a rough guide, i would be grateful, but either way, thnk you for your time.
Andrew
Pick n Mix Application Group.
Re: This has been bugging me for... ooh... AGES!! lol
Posted: Wed Jun 24, 2009 1:52 pm
by Eric!
just get the number of rows in your table ($end) and use an offset $x for how many of the last bits you want to see
SELECT * FROM table LIMIT '$end-$x','$end';
If you want to see the top $x rows just use limit
SELECT * FROM table LIMIT '$x';