catri3l Posted May 23, 2008 Share Posted May 23, 2008 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. Link to comment https://forums.phpfreaks.com/topic/107006-solved-problem-fetching-from-a-specific-date/ Share on other sites More sharing options...
Barand Posted May 23, 2008 Share Posted May 23, 2008 There's no table structure posted so let's assume you have a "feed_date" column in the feeds table. So I guess you need to add this the WHERE clause AND jbf.feed_date >= jb.buddy_date Link to comment https://forums.phpfreaks.com/topic/107006-solved-problem-fetching-from-a-specific-date/#findComment-548582 Share on other sites More sharing options...
catri3l Posted May 24, 2008 Author Share Posted May 24, 2008 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! Link to comment https://forums.phpfreaks.com/topic/107006-solved-problem-fetching-from-a-specific-date/#findComment-548641 Share on other sites More sharing options...
catri3l Posted May 24, 2008 Author Share Posted May 24, 2008 anyone please? Link to comment https://forums.phpfreaks.com/topic/107006-solved-problem-fetching-from-a-specific-date/#findComment-548909 Share on other sites More sharing options...
AndyB Posted May 24, 2008 Share Posted May 24, 2008 The code you give me i didnt try it yet ... So what would you like us to do next? And there's nothing wrong with multiple ANDs in query. Link to comment https://forums.phpfreaks.com/topic/107006-solved-problem-fetching-from-a-specific-date/#findComment-548921 Share on other sites More sharing options...
catri3l Posted May 24, 2008 Author Share Posted May 24, 2008 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. Link to comment https://forums.phpfreaks.com/topic/107006-solved-problem-fetching-from-a-specific-date/#findComment-548927 Share on other sites More sharing options...
catri3l Posted May 24, 2008 Author Share Posted May 24, 2008 Worked great! thank you so much! Link to comment https://forums.phpfreaks.com/topic/107006-solved-problem-fetching-from-a-specific-date/#findComment-548942 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.