"; include_once "$_SERVER[DOCUMENT_ROOT]/reviews/mysql2date.php"; include_once "$_SERVER[DOCUMENT_ROOT]/reviews/mysql_connect.php"; $page = $_GET["page"]; $search = $_GET["search"]; $ship = $_GET["ship"]; $order = $_GET["order"]; $sql = "select cruise_ship_id, cruise_ships.name as ship_name, cruise_lines.name as line_name from cruise_ships inner join cruise_lines using (cruise_line_id) order by line_name, ship_name"; $res = mysql_query($sql, $conn); while($rec = mysql_fetch_assoc($res)){ $lines[$rec["line_name"]][] = $rec; } $sql = "select SQL_CALC_FOUND_ROWS * from cruise_reviews"; if($ship || $search) $sql.= " where "; if($ship){ $clauses[] = " cruise_ship_id='".mysql_escape_string($ship)."'"; } if($search){ $terms = explode(" ", $search); $search_string = mysql_escape_string("+".implode(" +", $terms)); $clauses[] = "match (comments, cruise_ship_name, cruise_line_name) against ('$search_string' in boolean mode)"; } if($clauses){ $sql.= implode(" and ", $clauses); } if(empty($page)) $page = 1; $start = ($page*20) - 20; if(empty($order)){ $order = "date_added"; } switch ($order){ case "date_added": $dir = "desc"; $sort_col = "Date Added"; break; case "author": $dir = ""; $sort_col = "Author"; break; case "cruise_ship_name": $dir = ""; $sort_col = "Ship"; break; case "sail_date": $dir = "desc"; $sort_col = "Sail Date"; break; } $sql.= " order by ".mysql_escape_string($order)." $dir, cruise_review_id desc limit $start, 20"; $res = mysql_query($sql, $conn); echo mysql_error(); while($rec = mysql_fetch_assoc($res)){ $reviews[] = $rec; } $sql = "select found_rows() as total"; $res = mysql_query($sql, $conn); $total = mysql_result($res, 0, "total"); $qstring = "&search=".htmlspecialchars($search)."&ship=".htmlspecialchars($ship); // paging $pages = ceil($total/20); $prev = $page-1; $next = $page+1; if($prev>0){ $prev = "< Previous"; } else { $prev = ""; } if($next<=$pages){ $next = "Next >"; } else { $next = ""; } ?>

Cruise Reviews : Sorted By:
Ship:
Search:
Ship Author Sail Date Date Added
Page: of