I am making a feed system similar to the way facebook works now what I am trying to implement is the duplicate functionality.
if a user writes the same post= then don't display it duplicatly as PHP normally does by default but bump it up the top so users knows another user as re-wrote it
Here's my query
$select_posts_from_groups_query = $db->query("SELECT * FROM spud_groups_posts LEFT JOIN spud_groups_members
ON spud_groups_posts.group_url = spud_groups_members.gurl WHERE member_name='$mybb_username' GROUP BY post_body ORDER BY time_posted DESC" );
how can I get it to bump it self as the latest update once a user re duplicates it it would let users know that some one else has shared it
Thanks ;)
Three solutions
Assuming you have a update timing field on your data record called time_updated
, there are a couple of things you could do:
ORDER BY max(time_posted,time_updated) DESC
This might give issues with NULL
values though
NULL
s in the time_updated
ORDER BY nvl(time_updated, time_posted) DESC
(Oracle sql syntax nvl()
substitutes NULL
in the 1st param with the 2nd param - don't know what DB you are using)
time_updated
(the best solution IMO). When creating the post (initially) set time_updated = time_created
AND use
ORDER BY time_updated DESC