0) $filter_condition .= ' OR '; $filter_condition .= " title LIKE '$i%'"; } $filter_condition .= ")"; }else if ($filter != ''){ $filter_condition = " AND title LIKE '$filter%'"; } $qs = "/*all*/ select count(*) as cnt from ele_posts p, ele_users u where p.is_live = 1 and p.author_user_key = u.user_key and p.post_type_key=10 $filter_condition "; // $review_cnt = xone_column($qs, 'cnt'); $review_cnt = xnum_rows(xquery($qs, xconnect())); $qs .= " group by title order by post_dt desc "; $qs = str_replace("count(*) as cnt", "p.*,u.*", $qs) . " limit $start, $per_page "; $reviews = xall_rows($qs); $top_movies = xall_rows("SELECT title, round(avg(value)) as avg_value from ele_posts p, mbl_grades g where p.rating=g.rating and post_type_key=10 group by title, post_type_key having count(*) >= 2 order by avg_value limit 10 "); $top_users = xall_rows(" select username, round(average * 100) as rating from ele_users u, mbl_vote_info vi where u.user_key=vi.user_key order by average desc limit 10"); $most_reviews = xall_rows(" select username, count(*) as total_reviews from ele_posts p, ele_users u where p.author_user_key=u.user_key and p.post_type_key=10 group by username order by total_reviews desc limit 10 "); $letters = array(); $letters[] = array('filter' => 'All', 'value' => ''); $letters[] = array('filter' => '#', 'value' => urlencode('#')); for($i = 65; $i <= 90; $i++){ $letters[] = array('filter' => chr($i), 'value' => chr($i)); } for($i = 0; $i < count($top_movies); $i++){ $grade = ''; switch($top_movies[$i]['avg_value']){ case 1: $grade = 'A'; break; case 2: $grade = 'B'; break; case 3: $grade = 'C'; break; case 4: $grade = 'D'; break; case 5: $grade = 'F'; break; } $top_movies[$i]['rating'] = $grade; } display_template('reviews.phtml'); ?>