Jump to content

[SOLVED] problem fetching from a specific date!


catri3l

Recommended Posts

Hey. Couple of weeks ago i got help on a code which worked great! (thanks)

 

The code was to fetch a friends action feed from the db. However ive noticed that when a buddy becomes friends with another person on the site, all the actions from that person are added to the feed, making the list confusing. Because it displays and mixes all the actions of a new user with the existing ones

here is the code:

 

<?php

 

$fetch_feed = sql_query("SELECT * FROM joovili_buddies jb

JOIN joovili_buddy_feed jbf ON (jb.buddy_buddy = jbf.feed_username)

WHERE jb.buddy_username = '{$_COOKIE['session_username']}' AND jb.buddy_status='1'

ORDER BY jbf.id DESC LIMIT 15");

while ($feed = mysql_fetch_array($fetch_feed)){

 

?>

 

There is a buddy_date (which i added to the data base) and it shows the date those two person became friends. Is it possible to display the feed from a person starting from the date they became friends?

 

Thanks!

 

Ps: im using 'timestamp' for the date.

Hey, here are the table. The code you give me i didnt try it yet, how ever as you can see in the code there is already an "AND" I dont think it will work if i put another AND, and i cant remove the buddy_status="1" because it is the approval I use When requesting a friendship.

 

Thanks!

 

CREATE TABLE `joovili_buddies` (

  `buddy_id` int(11) NOT NULL auto_increment,

  `buddy_username` varchar(100) NOT NULL default '',

  `buddy_buddy` varchar(100) NOT NULL default '',

  `buddy_status` int(11) NOT NULL default '0',

  PRIMARY KEY  (`buddy_id`)

) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=29 ;

 

friend feed:

 

CREATE TABLE `joovili_buddy_feed` (

  `id` int(11) NOT NULL auto_increment,

  `feed_username` varchar(100) NOT NULL,

  `what_done` varchar(200) NOT NULL,

  `feed_date` varchar(200) NOT NULL default '0',

  PRIMARY KEY  (`id`)

) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=0 ;

 

I also added buddy_date to the joovili_buddy table!

 

Can I do this then?

 

<?php

 

$fetch_feed = sql_query("SELECT * FROM joovili_buddies jb

JOIN joovili_buddy_feed jbf ON (jb.buddy_buddy = jbf.feed_username)

WHERE jb.buddy_username = '{$_COOKIE['session_username']}' AND jb.buddy_status='1'

AND jbf.feed_date >= jb.buddy_date ORDER BY jbf.id DESC LIMIT 15");

while ($feed = mysql_fetch_array($fetch_feed)){

 

?>

 

Sorry I didnt know you could use multiples ANDs in a code!

 

Thank you.

Archived

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

×
×
  • Create New...

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.