doddsey_65 Posted February 17, 2011 Share Posted February 17, 2011 im joining a table onto the query to show how many likes a post has but it is displaying the post x amount of times depending on how many likes there are. I think its something to do with the way im joining onto the pid of the post table: $post_query = $link->query("SELECT p.*, u.*, l.* FROM ".TBL_PREFIX."posts as p JOIN ".TBL_PREFIX."users as u ON (u.u_username = p.p_poster) LEFT JOIN ".TBL_PREFIX."post_likes as l ON (l.l_pid = p.p_pid) WHERE p_tid = '$tid' ORDER BY p.p_time_posted ASC")or die(print_link_error()); $likes = array(); while($post_info = $post_query->fetch()) { // SOF LIKE LIST if (count($post_info['l_pid']) >= 1) { $likes[] = $post_info['l_username']; $amount_likes = count($likes); $slice = array_slice($likes, 0, 4, true); $remain = array_slice($likes, 4, $amount_likes, true); $remain_num = count($remain); $like_list = ''; if($amount_likes > 4) { for($i=0; $i<=3; $i++) { $like_list .= profile_link($likes[$i]).', '; } $like_list .= 'and '.$remain_num.' other like this'; } elseif($amount_likes <= 3) { for($i=0; $i<3; $i++) { $like_list .= profile_link($likes[$i]).' '; } $like_list .= 'like this'; } } the likes are stored in their own database table seperate from the posts any advice? Quote Link to comment Share on other sites More sharing options...
cgsmith105 Posted February 17, 2011 Share Posted February 17, 2011 Doddsey_65, Can you execute a var_dump() then exit() after setting $post_info to see what is going on? If it is displaying the post 10 times in a row because there are 10 likes then I would assume that it is the way the code displays the post and like on the page. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.