Advertisement
renai

show all with pagination

May 10th, 2012
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 55.00 KB | None | 0 0
  1. <?php
  2. include("inc/rating_functions.php");
  3. include("inc/rating_total_functions.php"); ?>
  4.  
  5. <!DOCTYPE HTML>
  6. <html>
  7. <head>
  8. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  9. <title>HIGH Access - Search</title>
  10. <link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
  11. <link rel="stylesheet" href="css/base.css" type="text/css" title="default"> <!-- default css -->
  12. <link rel="stylesheet" href="css/alternative.css" type="text/css" title="alternate"> <!-- alternative css -->
  13. <link rel="stylesheet" href="css/base2.css" type="text/css" title="third"> <!-- alternative css -->
  14. <script type="text/javascript" src="js/styleswitcher.js"></script> <!-- style switcher script -->
  15.  
  16. <link rel="stylesheet" type="text/css" href="css/rating_style.css" media="all">
  17. <script type="text/javascript" src="js/jquery.js"></script>
  18. <script type="text/javascript" src="js/rating_update.js"></script>
  19.  
  20. <script src="js/custom-form-elements.js" ></script> <!-- Required for custom form input -->
  21.  
  22. <!--[if lt IE 9]>
  23. <link rel="stylesheet" type="text/css" href="css/ie8.css" media="all" />
  24. <![endif]-->
  25.  
  26. <!--[if lt IE 7]>
  27. <style type="text/css">div, img { behavior: url(iepngfix.htc) }</style>
  28. <![endif]-->
  29.  
  30. <!--[if lt IE 9]>
  31. <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
  32. <![endif]-->
  33.  
  34. <script>
  35. var search;
  36. function search(){
  37. if(input[name=search].val() != null)
  38. {
  39. search = "q="+input[name=search].val();
  40. }
  41.  
  42. if(input[name=search_shop_experience].val() != null)
  43. {
  44. search += "search_shop_experience="+input[name=search_shop_experience].val();
  45. }
  46. if(input[name=search_shop_toilet_access].val() != null)
  47. {
  48. search += "search_shop_toilet_access="+input[name=search_shop_toilet_access].val();
  49. } }
  50. </script>
  51. </head>
  52. <!--[if lt IE 7 ]> <body class="ie6"> <![endif]-->
  53. <!--[if IE 7 ]> <body class="ie7"> <![endif]-->
  54. <!--[if IE 8 ]> <body class="ie8"> <![endif]-->
  55. <!--[if IE 9 ]> <body class="ie9"> <![endif]-->
  56. <!--[if (gt IE 9) ]> <body class="modern"> <![endif]-->
  57. <!--[!(IE)]><!--> <body class="notIE modern"> <!--<![endif]-->
  58.  
  59. <!-- REMOVE onLoad="initialize()" to fix js error on line 62 -->
  60. <div class="styleswitch">
  61. <a href="#" onclick="setActiveStyleSheet('default'); return false;">Default</a> or
  62. <a href="#" onclick="setActiveStyleSheet('alternate'); return false;">Alternate</a> or
  63. <a href="#" onclick="setActiveStyleSheet('third'); return false;">Third</a>
  64. </div>
  65. <div class="container">
  66. <div class="header_wrapper">
  67. <header>
  68. <?php require_once('inc/header.php'); ?>
  69.  
  70. <?php $search_total_rating_count = array(0,1,2,3,4,5);
  71.  
  72.  
  73. // put your default values here
  74. $defaults = array(
  75. 'search_shop_name' => '', 'search_shop_address' => '', 'search_shop_open' => '', 'search_shop_close' => '', 'search_open_now' => 'off',
  76. 'vapo' => '', 'snacks' => '', 'pool' => '', 'daccess' => '', 'tv' => '', 'games' => '', 'cat' => '', 'internet' => '', 'spacecake' => '', 'bud' => '',
  77. 'booze' => '', 'search_total_rating' => '0', 'search_shop_comfort' => '0', 'search_shop_service' => '0', 'search_shop_ambience' => '0', 'search_shop_friendliness' => '0', 'search_shop_spacious' => '0', 'search_shop_experience' => '0', 'search_shop_bud_quality' => '0', 'search_shop_bud_price' => '0', 'search_shop_drink_price' => '0', 'search_shop_space_cake' => '0', 'search_shop_accessibility' => '0', 'search_shop_toilet_access' => '0');
  78.  
  79. // merge $_GET in default values
  80. $input = array_merge($defaults, $_GET); // or $_GET + $defaults
  81.  
  82. // $search_shop_name = mysql_real_escape_string(stripslashes(strip_tags(htmlspecialchars($search_shop_name))));
  83.  
  84. //$search_shop_name = mysql_real_escape_string($input['search_shop_name']);
  85.  
  86. $vapo = $input['vapo'];
  87. $snacks = $input['snacks'];
  88. $pool = $input['pool'];
  89. $daccess = $input['daccess'];
  90. $tv = $input['tv'];
  91. $games = $input['games'];
  92. $cat = $input['cat'];
  93. $internet = $input['internet'];
  94. $spacecake = $input['spacecake'];
  95. $bud = $input['bud'];
  96. $booze = $input['booze'];
  97.  
  98. $search_total_rating = mysql_real_escape_string($input['search_total_rating']);
  99. $search_shop_comfort = mysql_real_escape_string($input['search_shop_comfort']);
  100. $search_shop_service = mysql_real_escape_string($input['search_shop_service']);
  101. $search_shop_ambience = mysql_real_escape_string($input['search_shop_ambience']);
  102. $search_shop_friendliness = mysql_real_escape_string($input['search_shop_friendliness']);
  103. $search_shop_spacious = mysql_real_escape_string($input['search_shop_spacious']);
  104. $search_shop_experience = $input['search_shop_experience'];
  105. $search_shop_bud_quality = $input['search_shop_bud_quality'];
  106. $search_shop_bud_price = $input['search_shop_bud_price'];
  107. $search_shop_drink_price = $input['search_shop_drink_price'];
  108. $search_shop_space_cake = $input['search_shop_space_cake'];
  109. $search_shop_accessibility = $input['search_shop_accessibility'];
  110.  
  111.  
  112. $search_shop_toilet_access = $input['search_shop_toilet_access'];
  113.  
  114.  
  115. //$search_total_rating = isset($_GET['search_total_rating']) ? $_GET['search_total_rating'] : ""; ?>
  116. </header>
  117. </div>
  118.  
  119. <section class="content">
  120. <h1>Search Coffeeshops</h1>
  121. <?php
  122.  
  123. $sort_by = isset($_GET['s']) ? $_GET['s'] : false;
  124.  
  125. date_default_timezone_set('Europe/Amsterdam');
  126. $nltime = date('H\:i');
  127. //$search_open_now = '07:00:00';
  128. $search_shop_name = mysql_real_escape_string($input['search_shop_name']); $search_shop_address = mysql_real_escape_string($input['search_shop_address']); $search_shop_open = mysql_real_escape_string($input['search_shop_open']);
  129. $search_open_now = mysql_real_escape_string($input['search_open_now']);
  130.  
  131. $search_total_rating_min = $search_total_rating-1;
  132. $search_total_rating_max = $search_total_rating+1;
  133.  
  134. print $search_total_rating_max;
  135.  
  136. if($search_open_now == "on") {
  137. $result = mysql_query("SELECT coffeeshops.*, services.*, ratings.*, temp.total as final_total, CONCAT(shop_number, ' ', shop_location, ' ', shop_city, ' ', shop_province, ' ', shop_postcode) AS address FROM coffeeshops
  138. inner join services on coffeeshops.shop_id=services.shop_id inner join ratings on coffeeshops.shop_id=ratings.shop_id
  139. inner join (select SUM(comfort + service + ambience + friendliness + spacious + experience + bud_quality + bud_price + drink_price + space_cake + accessibility + toilet_access)/(12) / COUNT(shop_id) AS total, shop_id FROM ratings GROUP BY shop_id ) as temp on coffeeshops.shop_id=temp.shop_id
  140. HAVING temp.total >= '$search_total_rating'
  141. AND address LIKE '%$search_shop_address%' AND shop_name LIKE '%$search_shop_name%' AND services_vapo LIKE '%$vapo%' AND services_pool LIKE '%$pool%' AND services_snacks LIKE '%$snacks%' AND services_disabled LIKE '%$daccess%' AND services_tv LIKE '%$tv%' AND services_games LIKE '%$games%' AND services_cat LIKE '%$cat%' AND services_internet LIKE '%$internet%' AND services_spacecake LIKE '%$spacecake%' AND services_bud LIKE '%$bud%' AND services_booze LIKE '%$booze%'
  142. AND comfort >= '$search_shop_comfort' AND service >= '$search_shop_service' AND ambience >= '$search_shop_ambience' AND friendliness >= '$search_shop_friendliness' AND spacious >= '$search_shop_spacious'
  143. AND experience >= '$search_shop_experience' AND bud_quality >= '$search_shop_bud_quality' AND bud_price >= '$search_shop_bud_price' AND drink_price >= '$search_shop_drink_price'
  144. AND space_cake >= '$search_shop_space_cake' AND accessibility >= '$search_shop_accessibility' AND toilet_access >= '$search_shop_toilet_access'
  145. AND (shop_open < shop_close AND '".$nltime."' BETWEEN shop_open AND shop_close) OR (shop_open > shop_close AND ('".$nltime."' >= shop_open OR '".$nltime."' < shop_close))
  146. ORDER BY shop_name ASC");
  147. } else {
  148. $result = mysql_query("SELECT coffeeshops.*, services.*, final_total
  149. FROM coffeeshops inner join services on coffeeshops.shop_id=services.shop_id
  150.  
  151. inner join (
  152. select avg(vote) AS final_total, shop_id FROM votes GROUP BY shop_id) as temp on coffeeshops.shop_id=temp.shop_id
  153. WHERE
  154. temp.final_total > ".$search_total_rating_min."
  155. AND
  156. temp.final_total < ".$search_total_rating_max."
  157.  
  158. AND shop_name LIKE '%$search_shop_name%'
  159.  
  160. AND services_vapo LIKE '%$vapo%' AND services_pool LIKE '%$pool%' AND services_snacks LIKE '%$snacks%'
  161. AND services_disabled LIKE '%$daccess%' AND services_tv LIKE '%$tv%' AND services_games LIKE '%$games%'
  162. AND services_cat LIKE '%$cat%' AND services_internet LIKE '%$internet%' AND services_spacecake LIKE '%$spacecake%'
  163. AND services_bud LIKE '%$bud%' AND services_booze LIKE '%$booze%'
  164. GROUP BY shop_name
  165.  
  166.  
  167. ORDER BY shop_name ASC");
  168. }
  169.  
  170.  
  171.  
  172. //$sql = "SELECT distinct coffeeshops.*, services.*, ratings.*, temp.total as final_total,
  173. //CONCAT(shop_number, ' ', shop_location, ' ', shop_city, ' ', shop_province, ' ', shop_postcode) AS address FROM coffeeshops
  174. //inner join services on coffeeshops.shop_id=services.shop_id
  175. ////inner join ratings on coffeeshops.shop_id=ratings.shop_id
  176. //inner join
  177. //(select SUM(comfort + service + ambience + friendliness + spacious + experience + bud_quality + bud_price + drink_price + space_cake + accessibility + toilet_access)/(12) / COUNT(shop_id) AS total, shop_id FROM ratings GROUP BY shop_id ) as temp on coffeeshops.shop_id=temp.shop_id
  178. //HAVING temp.total >= '$search_total_rating'
  179.  
  180. //////////////////////////////////// Adam's Pagination Logic ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  181. $nr = mysql_num_rows($result); // Get total of Num rows from the database query
  182. if (isset($_GET['pn'])) { // Get pn from URL vars if it is present
  183. $pn = preg_replace('#[^0-9]#i', '', $_GET['pn']); // filter everything but numbers for security(new)
  184. //$pn = ereg_replace("[^0-9]", "", $_GET['pn']); // filter everything but numbers for security(deprecated)
  185. } else { // If the pn URL variable is not present force it to be value of page number 1
  186. $pn = 1;
  187. }
  188.  
  189. $paginationNumber = "";
  190.  
  191. if(strlen($search_shop_name) > 0) {
  192. $paginationNumber .= '&amp;search_shop_name=' . $search_shop_name;
  193. }
  194. if(strlen($search_shop_address) > 0) {
  195. $paginationNumber .= '&amp;search_shop_address=' . $search_shop_address;
  196. }
  197. if($search_open_now == "on") {
  198. $paginationNumber .= '&amp;search_open_now=' . $search_open_now;
  199. }
  200. if($search_total_rating > 0) {
  201. $paginationNumber .= '&amp;search_total_rating=' . $search_total_rating;
  202. }
  203. if($vapo == "yes")
  204. {
  205. $paginationNumber .= '&amp;vapo=' . $vapo;
  206. }
  207. if($pool == "yes") {
  208. $paginationNumber .= '&amp;pool=' . $pool;
  209. }
  210. if($snacks == "yes") {
  211. $paginationNumber .= '&amp;snacks=' . $snacks;
  212. }
  213. if($daccess == "yes") {
  214. $paginationNumber .= '&amp;daccess=' . $daccess;
  215. }
  216. if($tv == "yes") {
  217. $paginationNumber .= '&amp;tv=' . $tv;
  218. }
  219. if($games == "yes") {
  220. $paginationNumber .= '&amp;games=' . $games;
  221. }
  222. if($cat == "yes") {
  223. $paginationNumber .= '&amp;cat=' . $cat;
  224. }
  225. if($internet == "yes") {
  226. $paginationNumber .= '&amp;internet=' . $internet;
  227. }
  228. if($spacecake == "yes") {
  229. $paginationNumber .= '&amp;spacecake=' . $spacecake;
  230. }
  231. if($bud == "yes") {
  232. $paginationNumber .= '&amp;bud=' . $bud;
  233. }
  234. if($booze == "yes") {
  235. $paginationNumber .= '&amp;booze=' . $booze;
  236. }
  237. if($search_shop_comfort > 0) {
  238. $paginationNumber .= '&amp;search_shop_comfort=' . $search_shop_comfort;
  239. }
  240. if($search_shop_service > 0) {
  241. $paginationNumber .= '&amp;search_shop_service=' . $search_shop_service;
  242. }
  243. if($search_shop_ambience > 0) {
  244. $paginationNumber .= '&amp;search_shop_ambience=' . $search_shop_ambience;
  245. }
  246. if($search_shop_friendliness > 0) {
  247. $paginationNumber .= '&amp;search_shop_friendliness=' . $search_shop_friendliness;
  248. }
  249. if($search_shop_spacious > 0) {
  250. $paginationNumber .= '&amp;search_shop_spacious=' . $search_shop_spacious;
  251. }
  252. if($search_shop_experience > 0) {
  253. $paginationNumber .= '&amp;search_shop_experience=' . $search_shop_experience;
  254. }
  255. if($search_shop_bud_quality > 0) {
  256. $paginationNumber .= '&amp;search_shop_bud_quality=' . $search_shop_bud_quality;
  257. }
  258. if($search_shop_bud_price > 0) {
  259. $paginationNumber .= '&amp;search_shop_bud_price=' . $search_shop_bud_price;
  260. }
  261. if($search_shop_drink_price > 0) {
  262. $paginationNumber .= '&amp;search_shop_drink_price=' . $search_shop_drink_price;
  263. }
  264. if($search_shop_space_cake > 0) {
  265. $paginationNumber .= '&amp;search_shop_space_cake=' . $search_shop_space_cake;
  266. }
  267. if($search_shop_accessibility > 0) {
  268. $paginationNumber .= '&amp;search_shop_accessibility=' . $search_shop_accessibility;
  269. }
  270. if($search_shop_toilet_access > 0) {
  271. $paginationNumber .= '&amp;search_shop_toilet_access=' . $search_shop_toilet_access;
  272. }
  273. //This is where we set how many database items to show on each page
  274. $itemsPerPage = 10;
  275. // Get the value of the last page in the pagination result set
  276. $lastPage = ceil($nr / $itemsPerPage);
  277. // Be sure URL variable $pn(page number) is no lower than page 1 and no higher than $lastpage
  278. if ($pn < 1) { // If it is less than 1
  279. $pn = 1; // force if to be 1
  280. } else if ($pn > $lastPage) { // if it is greater than $lastpage
  281. $pn = $lastPage; // force it to be $lastpage's value
  282. }
  283. // This creates the numbers to click in between the next and back buttons
  284. $centerPages = ""; // Initialize this variable
  285. $sub1 = $pn - 1;
  286. $sub2 = $pn - 2;
  287. $add1 = $pn + 1;
  288. $add2 = $pn + 2;
  289.  
  290. // Now we are going to run the same query as above but this time add $limit onto the end of the SQL syntax
  291. // $sql2 is what we will use to fuel our while loop statement below
  292. switch ($sort_by) {
  293. case 'shop_name':
  294. case 'shop_id':
  295. case 'final_total':
  296. break;
  297. default:
  298. $sort_by = 'shop_name';
  299. }
  300. // get the direction, or use the default
  301. $direction = isset($_GET['d']) ? $_GET['d'] : 'ASC';
  302. if ($direction != 'ASC' && $direction != 'DESC') {
  303. $direction = 'ASC'; }
  304. $paginationDisplay = ""; // Initialize the pagination output variable
  305.  
  306.  
  307. // This creates the numbers to click in between the next and back buttons
  308.  
  309.  
  310. if ($pn == 1) {
  311. $centerPages .= '&nbsp; <span class="pagNumActive">' . $pn . '</span> &nbsp;';
  312. $centerPages .= '&nbsp; <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $add1 . '&amp;s=' . $sort_by . '&amp;d='. $direction . $paginationNumber . '&amp;submit">' . $add1 . '</a> &nbsp;';
  313. } else if ($pn == $lastPage) {
  314. $centerPages .= '&nbsp; <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $sub1 . '&amp;s=' . $sort_by . '&amp;d='. $direction . $paginationNumber .'&amp;submit">' . $sub1 . '</a> &nbsp;';
  315. $centerPages .= '&nbsp; <span class="pagNumActive">' . $pn . '</span> &nbsp;';
  316. } else if ($pn > 2 && $pn < ($lastPage - 1)) {
  317. $centerPages .= '&nbsp; <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $sub2 . '&amp;s=' . $sort_by . '&amp;d='. $direction . $paginationNumber .'&amp;submit">' . $sub2 . '</a> &nbsp;';
  318. $centerPages .= '&nbsp; <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $sub1 . '&amp;s=' . $sort_by . '&amp;d='. $direction . $paginationNumber .'&amp;submit">' . $sub1 . '</a> &nbsp;';
  319. $centerPages .= '&nbsp; <span class="pagNumActive">' . $pn . '</span> &nbsp;';
  320. $centerPages .= '&nbsp; <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $add1 . '&amp;s=' . $sort_by . '&amp;d='. $direction . $paginationNumber .'&amp;submit">' . $add1 . '</a> &nbsp;';
  321. $centerPages .= '&nbsp; <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $add2 . '&amp;s=' . $sort_by . '&amp;d='. $direction . $paginationNumber .'&amp;submit">' . $add2 . '</a> &nbsp;';
  322. } else if ($pn > 1 && $pn < $lastPage) {
  323. $centerPages .= '&nbsp; <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $sub1 . '&amp;s=' . $sort_by . '&amp;d='. $direction . $paginationNumber .'&amp;submit">' . $sub1 . '</a> &nbsp;';
  324. $centerPages .= '&nbsp; <span class="pagNumActive">' . $pn . '</span> &nbsp;';
  325. $centerPages .= '&nbsp; <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $add1 . '&amp;s=' . $sort_by . '&amp;d='. $direction . $paginationNumber .'&amp;submit">' . $add1 . '</a> &nbsp;';
  326. }
  327. // This line sets the "LIMIT" range... the 2 values we place to choose a range of rows from database in our query
  328. $limit = 'LIMIT ' .($pn - 1) * $itemsPerPage .',' .$itemsPerPage;
  329. // Now we are going to run the same query as above but this time add $limit onto the end of the SQL syntax
  330.  
  331.  
  332. // This code runs only if the last page variable is not equal to 1, if it is only 1 page we require no paginated links to display
  333. if ($lastPage != "1"){
  334. // This shows the user what page they are on, and the total number of pages
  335. $paginationDisplay .= '<span class="pagesof">Page <strong>' . $pn . '</strong> of ' . $lastPage. '</span><img src="img/clearImage.gif" width="20" height="1" alt="Spacer" />';
  336. // If we are not on page 1 we can place the Back button
  337. if ($pn != 1) {
  338. $previous = $pn - 1;
  339. $paginationDisplay .= '&nbsp; <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $previous . '&amp;s=' . $sort_by .'&amp;d='. $direction;
  340.  
  341. if(strlen($search_shop_name) > 0) {
  342. $paginationDisplay .= '&amp;search_shop_name=' . $search_shop_name;
  343. }
  344. if(strlen($search_shop_address) > 0) {
  345. $paginationDisplay .= '&amp;search_shop_address=' . $search_shop_address;
  346. }
  347. if($search_open_now == "on") {
  348. $paginationDisplay .= '&amp;search_open_now=' . $search_open_now;
  349. }
  350. if($search_total_rating > 0) {
  351. $paginationDisplay .= '&amp;search_total_rating=' . $search_total_rating;
  352. }
  353. if($vapo == "yes")
  354. {
  355. $paginationDisplay .= '&amp;vapo=' . $vapo;
  356. }
  357. if($pool == "yes") {
  358. $paginationDisplay .= '&amp;pool=' . $pool;
  359. }
  360. if($snacks == "yes") {
  361. $paginationDisplay .= '&amp;snacks=' . $snacks;
  362. }
  363. if($daccess == "yes") {
  364. $paginationDisplay .= '&amp;daccess=' . $daccess;
  365. }
  366. if($tv == "yes") {
  367. $paginationDisplay .= '&amp;tv=' . $tv;
  368. }
  369. if($games == "yes") {
  370. $paginationDisplay .= '&amp;games=' . $games;
  371. }
  372. if($cat == "yes") {
  373. $paginationDisplay .= '&amp;cat=' . $cat;
  374. }
  375. if($internet == "yes") {
  376. $paginationDisplay .= '&amp;internet=' . $internet;
  377. }
  378. if($spacecake == "yes") {
  379. $paginationDisplay .= '&amp;spacecake=' . $spacecake;
  380. }
  381. if($bud == "yes") {
  382. $paginationDisplay .= '&amp;bud=' . $bud;
  383. }
  384. if($booze == "yes") {
  385. $paginationDisplay .= '&amp;booze=' . $booze;
  386. }
  387. if($search_shop_comfort > 0) {
  388. $paginationDisplay .= '&amp;search_shop_comfort=' . $search_shop_comfort;
  389. }
  390. if($search_shop_service > 0) {
  391. $paginationDisplay .= '&amp;search_shop_service=' . $search_shop_service;
  392. }
  393. if($search_shop_ambience > 0) {
  394. $paginationDisplay .= '&amp;search_shop_ambience=' . $search_shop_ambience;
  395. }
  396. if($search_shop_friendliness > 0) {
  397. $paginationDisplay .= '&amp;search_shop_friendliness=' . $search_shop_friendliness;
  398. }
  399. if($search_shop_spacious > 0) {
  400. $paginationDisplay .= '&amp;search_shop_spacious=' . $search_shop_spacious;
  401. }
  402. if($search_shop_experience > 0) {
  403. $paginationDisplay .= '&amp;search_shop_experience=' . $search_shop_experience;
  404. }
  405. if($search_shop_bud_quality > 0) {
  406. $paginationDisplay .= '&amp;search_shop_bud_quality=' . $search_shop_bud_quality;
  407. }
  408. if($search_shop_bud_price > 0) {
  409. $paginationDisplay .= '&amp;search_shop_bud_price=' . $search_shop_bud_price;
  410. }
  411. if($search_shop_drink_price > 0) {
  412. $paginationDisplay .= '&amp;search_shop_drink_price=' . $search_shop_drink_price;
  413. }
  414. if($search_shop_space_cake > 0) {
  415. $paginationDisplay .= '&amp;search_shop_space_cake=' . $search_shop_space_cake;
  416. }
  417. if($search_shop_accessibility > 0) {
  418. $paginationDisplay .= '&amp;search_shop_accessibility=' . $search_shop_accessibility;
  419. }
  420. if($search_shop_toilet_access > 0) {
  421. $paginationDisplay .= '&amp;search_shop_toilet_access=' . $search_shop_toilet_access;
  422. }
  423. $paginationDisplay .= '&amp;submit"> Back</a> ';
  424. }
  425. // Lay in the clickable numbers display here between the Back and Next links
  426. $paginationDisplay .= '<span class="paginationNumbers">' . $centerPages . '</span>';
  427. // If we are not on the very last page we can place the Next button
  428. if ($pn != $lastPage) {
  429. $nextPage = $pn + 1;
  430. $paginationDisplay .= '&nbsp; <a href="' . $_SERVER['PHP_SELF'] . '?pn=' . $nextPage . '&amp;s=' . $sort_by .'&amp;d=' . $direction;
  431.  
  432. if(strlen($search_shop_name) > 0) {
  433. $paginationDisplay .= '&amp;search_shop_name=' . $search_shop_name;
  434. }
  435. if(strlen($search_shop_address) > 0) {
  436. $paginationDisplay .= '&amp;search_shop_address=' . $search_shop_address;
  437. }
  438. if($search_open_now == "on") {
  439. $paginationDisplay .= '&amp;search_open_now=' . $search_open_now;
  440. }
  441. if($search_total_rating > 0) {
  442. $paginationDisplay .= '&amp;search_total_rating=' . $search_total_rating;
  443. }
  444. if($vapo == "yes")
  445. {
  446. $paginationDisplay .= '&amp;vapo=' . $vapo;
  447. }
  448. if($pool == "yes") {
  449. $paginationDisplay .= '&amp;pool=' . $pool;
  450. }
  451. if($snacks == "yes") {
  452. $paginationDisplay .= '&amp;snacks=' . $snacks;
  453. }
  454. if($daccess == "yes") {
  455. $paginationDisplay .= '&amp;daccess=' . $daccess;
  456. }
  457. if($tv == "yes") {
  458. $paginationDisplay .= '&amp;tv=' . $tv;
  459. }
  460. if($games == "yes") {
  461. $paginationDisplay .= '&amp;games=' . $games;
  462. }
  463. if($cat == "yes") {
  464. $paginationDisplay .= '&amp;cat=' . $cat;
  465. }
  466. if($internet == "yes") {
  467. $paginationDisplay .= '&amp;internet=' . $internet;
  468. }
  469. if($spacecake == "yes") {
  470. $paginationDisplay .= '&amp;spacecake=' . $spacecake;
  471. }
  472. if($bud == "yes") {
  473. $paginationDisplay .= '&amp;bud=' . $bud;
  474. }
  475. if($booze == "yes") {
  476. $paginationDisplay .= '&amp;booze=' . $booze;
  477. }
  478. if($search_shop_comfort > 0) {
  479. $paginationDisplay .= '&amp;search_shop_comfort=' . $search_shop_comfort;
  480. }
  481. if($search_shop_service > 0) {
  482. $paginationDisplay .= '&amp;search_shop_service=' . $search_shop_service;
  483. }
  484. if($search_shop_ambience > 0) {
  485. $paginationDisplay .= '&amp;search_shop_ambience=' . $search_shop_ambience;
  486. }
  487. if($search_shop_friendliness > 0) {
  488. $paginationDisplay .= '&amp;search_shop_friendliness=' . $search_shop_friendliness;
  489. }
  490. if($search_shop_spacious > 0) {
  491. $paginationDisplay .= '&amp;search_shop_spacious=' . $search_shop_spacious;
  492. }
  493. if($search_shop_experience > 0) {
  494. $paginationDisplay .= '&amp;search_shop_experience=' . $search_shop_experience;
  495. }
  496. if($search_shop_bud_quality > 0) {
  497. $paginationDisplay .= '&amp;search_shop_bud_quality=' . $search_shop_bud_quality;
  498. }
  499. if($search_shop_bud_price > 0) {
  500. $paginationDisplay .= '&amp;search_shop_bud_price=' . $search_shop_bud_price;
  501. }
  502. if($search_shop_drink_price > 0) {
  503. $paginationDisplay .= '&amp;search_shop_drink_price=' . $search_shop_drink_price;
  504. }
  505. if($search_shop_space_cake > 0) {
  506. $paginationDisplay .= '&amp;search_shop_space_cake=' . $search_shop_space_cake;
  507. }
  508. if($search_shop_accessibility > 0) {
  509. $paginationDisplay .= '&amp;search_shop_accessibility=' . $search_shop_accessibility;
  510. }
  511. if($search_shop_toilet_access > 0) {
  512. $paginationDisplay .= '&amp;search_shop_toilet_access=' . $search_shop_toilet_access;
  513. }
  514. $paginationDisplay .= '&submit"> Next</a> ';
  515.  
  516.  
  517. }
  518. } // check for sort field
  519. // validate the sort field (avoid Bobby Tables!) and provide default
  520.  
  521. // used in table heading to indicate sort direciton
  522. $sort_arrow = ($direction == 'ASC' ? '<img src="img/up_arrow.png" alt="Descend" />' : '<img src="img/down_arrow.png" alt="Ascend" />');
  523.  
  524. // used to build urls to reverse the current sort direction
  525. $reverse_direction = ($direction == 'DESC' ? 'ASC' : 'DESC');
  526. // build the basis for the query
  527. if($search_open_now == "on") {
  528. $sql="SELECT coffeeshops.*, services.*, ratings.*, temp.total as final_total, CONCAT(shop_number, ' ', shop_location, ' ', shop_city, ' ', shop_province, ' ', shop_postcode) AS address FROM coffeeshops
  529. inner join services on coffeeshops.shop_id=services.shop_id inner join ratings on coffeeshops.shop_id=ratings.shop_id
  530. inner join (select SUM(comfort + service + ambience + friendliness + spacious + experience + bud_quality + bud_price + drink_price + space_cake + accessibility + toilet_access)/(12) / COUNT(shop_id) AS total, shop_id FROM ratings GROUP BY shop_id ) as temp on coffeeshops.shop_id=temp.shop_id
  531. WHERE (shop_open < shop_close AND '".$nltime."' BETWEEN shop_open AND shop_close) OR (shop_open > shop_close AND ('".$nltime."' >= shop_open OR '".$nltime."' < shop_close))
  532. HAVING temp.total >= '$search_total_rating'
  533. AND address LIKE '%$search_shop_address%' AND shop_name LIKE '%$search_shop_name%'
  534. AND services_vapo LIKE '%$vapo%' AND services_pool LIKE '%$pool%' AND services_snacks LIKE '%$snacks%' AND services_disabled LIKE '%$daccess%' AND services_tv LIKE '%$tv%' AND services_games LIKE '%$games%' AND services_cat LIKE '%$cat%' AND services_internet LIKE '%$internet%' AND services_spacecake LIKE '%$spacecake%' AND services_bud LIKE '%$bud%' AND services_booze LIKE '%$booze%'
  535. AND comfort >= '$search_shop_comfort' AND service >= '$search_shop_service' AND ambience >= '$search_shop_ambience' AND friendliness >= '$search_shop_friendliness' AND spacious >= '$search_shop_spacious' AND experience >= '$search_shop_experience' AND bud_quality >= '$search_shop_bud_quality' AND bud_price >= '$search_shop_bud_price' AND drink_price >= '$search_shop_drink_price' AND space_cake >= '$search_shop_space_cake' AND accessibility >= '$search_shop_accessibility' AND toilet_access >= '$search_shop_toilet_access' ORDER BY shop_name ASC";
  536. }
  537.  
  538. else {
  539. $on_shopname = "AND shop_name LIKE '%$search_shop_name%'";
  540. $sql = "SELECT coffeeshops.*, services.*, final_total
  541. FROM coffeeshops inner join services on coffeeshops.shop_id=services.shop_id
  542.  
  543. inner join (select avg(vote) AS final_total, shop_id FROM votes GROUP BY shop_id) as temp on coffeeshops.shop_id=temp.shop_id
  544.  
  545. WHERE final_total >= '$search_total_rating'
  546. AND shop_name LIKE '%$search_shop_name%'
  547.  
  548. AND services_vapo LIKE '%$vapo%' AND services_pool LIKE '%$pool%' AND services_snacks LIKE '%$snacks%'
  549. AND services_disabled LIKE '%$daccess%' AND services_tv LIKE '%$tv%' AND services_games LIKE '%$games%'
  550. AND services_cat LIKE '%$cat%' AND services_internet LIKE '%$internet%' AND services_spacecake LIKE '%$spacecake%'
  551. AND services_bud LIKE '%$bud%' AND services_booze LIKE '%$booze%'
  552.  
  553. GROUP BY shop_name
  554. ORDER BY $sort_by $direction ,shop_name ASC $limit";
  555.  
  556.  
  557.  
  558.  
  559. //$sql = "SELECT distinct coffeeshops.*, services.*, ratings.*, temp.total as final_total,
  560. //CONCAT(shop_number, ' ', shop_location, ' ', shop_city, ' ', shop_province, ' ', shop_postcode) AS address FROM coffeeshops
  561. //inner join services on coffeeshops.shop_id=services.shop_id
  562. ////inner join ratings on coffeeshops.shop_id=ratings.shop_id
  563. //inner join
  564. //(select SUM(comfort + service + ambience + friendliness + spacious + experience + bud_quality + bud_price + drink_price + space_cake + accessibility + toilet_access)/(12) / COUNT(shop_id) AS total, shop_id FROM ratings GROUP BY shop_id ) as temp on coffeeshops.shop_id=temp.shop_id
  565. //HAVING temp.total >= '$search_total_rating'
  566. //AND address LIKE '%$search_shop_address%' AND shop_name LIKE '%$search_shop_name%'
  567. //AND toilet_access >= '$search_shop_toilet_access'
  568. //ORDER BY $sort_by $direction $limit";
  569. }
  570. // execute query, get results
  571. $res = mysql_query($sql);
  572. $results = array();
  573. if ($res) {
  574. while ($row = mysql_fetch_assoc($res)) {
  575. $results[] = $row;
  576. }
  577. //print_r($results);
  578.  
  579. }
  580. // print $sql;
  581. $numrows = mysql_num_rows($result);
  582. if ($numrows == 0) {
  583. echo "<div id='legend_nodata'><span>No matches found, try again!</span></div>";
  584. // exit;
  585. }
  586. echo $numrows;
  587. ///////////////////////////////////// END Adam's Pagination Display Setup /////////////////////////////////////////////////////
  588. // Build the Output Section Here
  589. ?>
  590. <form id="search_form" action="<?php echo "search.php#legend_total_results"; ?>" method="GET">
  591. <fieldset class="search_basic">
  592. <legend>Search by Criteria</legend>
  593. <ol>
  594. <li>
  595. <label for="search_shop_name">Coffeeshop:</label>
  596. <input type="text" name="search_shop_name" id="search_shop_name" value="<?php echo htmlspecialchars($search_shop_name); ?>" />
  597. </li>
  598. <li>
  599. <label for="search_shop_address">Address:</label>
  600. <input type="text" name="search_shop_address" id="search_shop_address" value="<?php echo htmlspecialchars($search_shop_address); ?>" />
  601. </li>
  602. <li>
  603. <label for="search_total_rating">Total Rating:</label>
  604. <select name="search_total_rating" id="search_total_rating">
  605. <option value="0" <?php if($search_total_rating == '0') echo 'selected="selected"'; ?>>0</option>
  606. <option value="1" <?php if($search_total_rating == '1') echo 'selected="selected"'; ?>>1</option>
  607. <option value="2" <?php if($search_total_rating == '2') echo 'selected="selected"'; ?>>2</option>
  608. <option value="3" <?php if($search_total_rating == '3') echo 'selected="selected"'; ?>>3</option>
  609. <option value="4" <?php if($search_total_rating == '4') echo 'selected="selected"'; ?>>4</option>
  610. <option value="5" <?php if($search_total_rating == '5') echo 'selected="selected"'; ?>>5</option>
  611. </select>
  612. </li>
  613. <li>
  614. <label for="search_open_now">Open Now:</label>
  615. <input type="checkbox" name="search_open_now" class="styled" id="search_open_now" <?php if ($search_open_now == "on") { echo 'checked=\'yes\''; } ?> />
  616. </li>
  617. </ol>
  618. </fieldset>
  619.  
  620. <fieldset class="search_services" >
  621. <legend>Search by Services</legend>
  622. <ol>
  623. <li>
  624. <label for="vapo">Vapo:</label>
  625. <input id="vapo" name="vapo" type="checkbox" class="styled" value="yes" <?php if($vapo == 'yes') echo 'checked="checked"'; ?> />
  626. </li>
  627. <li class="format_services">
  628. <label for="pool">Pool:</label>
  629. <input id="pool" name="pool" type="checkbox" class="styled" value="yes" <?php if($pool == 'yes') echo 'checked="checked"'; ?> />
  630. </li>
  631. <li class="format_services">
  632. <label for="snacks">Snacks:</label>
  633. <input id="snacks" name="snacks" type="checkbox" class="styled" value="yes" <?php if($snacks == 'yes') echo 'checked="checked"'; ?> />
  634. </li>
  635. <li>
  636. <label for="tv">Tv:</label>
  637. <input id="tv" name="tv" type="checkbox" class="styled" value="yes" <?php if($tv == 'yes') echo 'checked="checked"'; ?>>
  638. </li>
  639. <li class="format_services">
  640. <label for="games">Games:</label>
  641. <input id="games" name="games" type="checkbox" class="styled" value="yes" <?php if($games == 'yes') echo 'checked="checked"'; ?>>
  642. </li>
  643. <li class="format_services">
  644. <label for="internet">Internet:</label>
  645. <input id="internet" name="internet" type="checkbox" class="styled" value="yes" <?php if($internet == 'yes') echo 'checked="checked"'; ?> />
  646. </li>
  647. <li>
  648. <label for="spacecake">Space Cake:</label>
  649. <input id="spacecake" name="spacecake" type="checkbox" class="styled" value="yes" <?php if($spacecake == 'yes') echo 'checked="checked"'; ?> />
  650. </li>
  651. <li class="format_services">
  652. <label for="bud">Bud:</label>
  653. <input id="bud" name="bud" type="checkbox" class="styled" value="yes" <?php if($bud == 'yes') echo 'checked="checked"'; ?> />
  654. </li>
  655. <li class="format_services">
  656. <label for="cat">Cat:</label>
  657. <input id="cat" name="cat" type="checkbox" class="styled" value="yes" <?php if($cat == 'yes') echo 'checked="checked"'; ?> />
  658. </li>
  659. <li>
  660. <label for="daccess">Mobility access:</label>
  661. <input id="daccess" name="daccess" type="checkbox" class="styled" value="yes" <?php if($daccess == 'yes') echo 'checked="checked"'; ?> />
  662. </li>
  663. </ol>
  664. </fieldset>
  665.  
  666. <fieldset class="search_ratings">
  667. <legend>Search by Ratings</legend>
  668. <ol>
  669. <li>
  670. <label for="search_shop_comfort">Comfort:</label>
  671. <select name="search_shop_comfort" id="search_shop_comfort">
  672. <option value="0" <?php if($search_shop_comfort == '0') echo 'selected="selected"'; ?>>0</option>
  673. <option value="1" <?php if($search_shop_comfort == '1') echo 'selected="selected"'; ?>>1</option>
  674. <option value="2" <?php if($search_shop_comfort == '2') echo 'selected="selected"'; ?>>2</option>
  675. <option value="3" <?php if($search_shop_comfort == '3') echo 'selected="selected"'; ?>>3</option>
  676. <option value="4" <?php if($search_shop_comfort == '4') echo 'selected="selected"'; ?>>4</option>
  677. <option value="5" <?php if($search_shop_comfort == '5') echo 'selected="selected"'; ?>>5</option>
  678. </select>
  679. </li>
  680. <li>
  681. <label for="search_shop_service">Service:</label>
  682. <select name="search_shop_service" id="search_shop_service">
  683. <option value="0" <?php if($search_shop_service == '0') echo 'selected="selected"'; ?>>0</option>
  684. <option value="1" <?php if($search_shop_service == '1') echo 'selected="selected"'; ?>>1</option>
  685. <option value="2" <?php if($search_shop_service == '2') echo 'selected="selected"'; ?>>2</option>
  686. <option value="3" <?php if($search_shop_service == '3') echo 'selected="selected"'; ?>>3</option>
  687. <option value="4" <?php if($search_shop_service == '4') echo 'selected="selected"'; ?>>4</option>
  688. <option value="5" <?php if($search_shop_service == '5') echo 'selected="selected"'; ?>>5</option>
  689. </select>
  690. </li>
  691. <li>
  692. <label for="search_shop_ambience">Ambience:</label>
  693. <select name="search_shop_ambience" id="search_shop_ambience">
  694. <option value="0" <?php if($search_shop_ambience == '0') echo 'selected="selected"'; ?>>0</option>
  695. <option value="1" <?php if($search_shop_ambience == '1') echo 'selected="selected"'; ?>>1</option>
  696. <option value="2" <?php if($search_shop_ambience == '2') echo 'selected="selected"'; ?>>2</option>
  697. <option value="3" <?php if($search_shop_ambience == '3') echo 'selected="selected"'; ?>>3</option>
  698. <option value="4" <?php if($search_shop_ambience == '4') echo 'selected="selected"'; ?>>4</option>
  699. <option value="5" <?php if($search_shop_ambience == '5') echo 'selected="selected"'; ?>>5</option>
  700. </select>
  701. </li>
  702. <li>
  703. <label for="search_shop_friendliness">Friendliness:</label>
  704. <select name="search_shop_friendliness" id="search_shop_friendliness">
  705. <option value="0" <?php if($search_shop_friendliness == '0') echo 'selected="selected"'; ?>>0</option>
  706. <option value="1" <?php if($search_shop_friendliness == '1') echo 'selected="selected"'; ?>>1</option>
  707. <option value="2" <?php if($search_shop_friendliness == '2') echo 'selected="selected"'; ?>>2</option>
  708. <option value="3" <?php if($search_shop_friendliness == '3') echo 'selected="selected"'; ?>>3</option>
  709. <option value="4" <?php if($search_shop_friendliness == '4') echo 'selected="selected"'; ?>>4</option>
  710. <option value="5" <?php if($search_shop_friendliness == '5') echo 'selected="selected"'; ?>>5</option>
  711. </select>
  712. </li>
  713. <li>
  714. <label for="search_shop_spacious">Spacious:</label>
  715. <select name="search_shop_spacious" id="search_shop_spacious">
  716. <option value="0" <?php if($search_shop_spacious == '0') echo 'selected="selected"'; ?>>0</option>
  717. <option value="1" <?php if($search_shop_spacious == '1') echo 'selected="selected"'; ?>>1</option>
  718. <option value="2" <?php if($search_shop_spacious == '2') echo 'selected="selected"'; ?>>2</option>
  719. <option value="3" <?php if($search_shop_spacious == '3') echo 'selected="selected"'; ?>>3</option>
  720. <option value="4" <?php if($search_shop_spacious == '4') echo 'selected="selected"'; ?>>4</option>
  721. <option value="5" <?php if($search_shop_spacious == '5') echo 'selected="selected"'; ?>>5</option>
  722. </select>
  723. </li>
  724. <li>
  725. <label for="search_shop_experience">Experience:</label>
  726. <select name="search_shop_experience" id="search_shop_experience">
  727. <option value="0" <?php if($search_shop_experience == '0') echo 'selected="selected"'; ?>>0</option>
  728. <option value="1" <?php if($search_shop_experience == '1') echo 'selected="selected"'; ?>>1</option>
  729. <option value="2" <?php if($search_shop_experience == '2') echo 'selected="selected"'; ?>>2</option>
  730. <option value="3" <?php if($search_shop_experience == '3') echo 'selected="selected"'; ?>>3</option>
  731. <option value="4" <?php if($search_shop_experience == '4') echo 'selected="selected"'; ?>>4</option>
  732. <option value="5" <?php if($search_shop_experience == '5') echo 'selected="selected"'; ?>>5</option>
  733. </select>
  734. </li>
  735. <li>
  736. <label for="search_shop_bud_quality">Bud quality:</label>
  737. <select name="search_shop_bud_quality" id="search_shop_bud_quality">
  738. <option value="0" <?php if($search_shop_bud_quality == '0') echo 'selected="selected"'; ?>>0</option>
  739. <option value="1" <?php if($search_shop_bud_quality == '1') echo 'selected="selected"'; ?>>1</option>
  740. <option value="2" <?php if($search_shop_bud_quality == '2') echo 'selected="selected"'; ?>>2</option>
  741. <option value="3" <?php if($search_shop_bud_quality == '3') echo 'selected="selected"'; ?>>3</option>
  742. <option value="4" <?php if($search_shop_bud_quality == '4') echo 'selected="selected"'; ?>>4</option>
  743. <option value="5" <?php if($search_shop_bud_quality == '5') echo 'selected="selected"'; ?>>5</option>
  744. </select>
  745. </li>
  746. <li>
  747. <label for="search_shop_bud_price">Bud price:</label>
  748. <select name="search_shop_bud_price" id="search_shop_bud_price">
  749. <option value="0" <?php if($search_shop_bud_price == '0') echo 'selected="selected"'; ?>>0</option>
  750. <option value="1" <?php if($search_shop_bud_price == '1') echo 'selected="selected"'; ?>>1</option>
  751. <option value="2" <?php if($search_shop_bud_price == '2') echo 'selected="selected"'; ?>>2</option>
  752. <option value="3" <?php if($search_shop_bud_price == '3') echo 'selected="selected"'; ?>>3</option>
  753. <option value="4" <?php if($search_shop_bud_price == '4') echo 'selected="selected"'; ?>>4</option>
  754. <option value="5" <?php if($search_shop_bud_price == '5') echo 'selected="selected"'; ?>>5</option>
  755. </select>
  756. </li>
  757. <li>
  758. <label for="search_shop_drink_price">Drink Price:</label>
  759. <select name="search_shop_drink_price" id="search_shop_drink_price">
  760. <option value="0" <?php if($search_shop_drink_price == '0') echo 'selected="selected"'; ?>>0</option>
  761. <option value="1" <?php if($search_shop_drink_price == '1') echo 'selected="selected"'; ?>>1</option>
  762. <option value="2" <?php if($search_shop_drink_price == '2') echo 'selected="selected"'; ?>>2</option>
  763. <option value="3" <?php if($search_shop_drink_price == '3') echo 'selected="selected"'; ?>>3</option>
  764. <option value="4" <?php if($search_shop_drink_price == '4') echo 'selected="selected"'; ?>>4</option>
  765. <option value="5" <?php if($search_shop_drink_price == '5') echo 'selected="selected"'; ?>>5</option>
  766. </select>
  767. </li>
  768. <li>
  769. <label for="search_shop_space_cake">Space cake:</label>
  770. <select name="search_shop_space_cake" id="search_shop_space_cake">
  771. <option value="0" <?php if($search_shop_space_cake == '0') echo 'selected="selected"'; ?>>0</option>
  772. <option value="1" <?php if($search_shop_space_cake == '1') echo 'selected="selected"'; ?>>1</option>
  773. <option value="2" <?php if($search_shop_space_cake == '2') echo 'selected="selected"'; ?>>2</option>
  774. <option value="3" <?php if($search_shop_space_cake == '3') echo 'selected="selected"'; ?>>3</option>
  775. <option value="4" <?php if($search_shop_space_cake == '4') echo 'selected="selected"'; ?>>4</option>
  776. <option value="5" <?php if($search_shop_space_cake == '5') echo 'selected="selected"'; ?>>5</option>
  777. </select>
  778. </li>
  779. <li>
  780. <label for="search_shop_accessibility">Accessibility:</label>
  781. <select name="search_shop_accessibility" id="search_shop_accessibility">
  782. <option value="0" <?php if($search_shop_accessibility == '0') echo 'selected="selected"'; ?>>0</option>
  783. <option value="1" <?php if($search_shop_accessibility == '1') echo 'selected="selected"'; ?>>1</option>
  784. <option value="2" <?php if($search_shop_accessibility == '2') echo 'selected="selected"'; ?>>2</option>
  785. <option value="3" <?php if($search_shop_accessibility == '3') echo 'selected="selected"'; ?>>3</option>
  786. <option value="4" <?php if($search_shop_accessibility == '4') echo 'selected="selected"'; ?>>4</option>
  787. <option value="5" <?php if($search_shop_accessibility == '5') echo 'selected="selected"'; ?>>5</option>
  788. </select>
  789. </li>
  790. <li>
  791. <label for="search_shop_toilet_access">Toilet access:</label>
  792. <select name="search_shop_toilet_access" id="search_shop_toilet_access">
  793. <option value="0" <?php if($search_shop_toilet_access == '0') echo 'selected="selected"'; ?>>0</option>
  794. <option value="1" <?php if($search_shop_toilet_access == '1') echo 'selected="selected"'; ?>>1</option>
  795. <option value="2" <?php if($search_shop_toilet_access == '2') echo 'selected="selected"'; ?>>2</option>
  796. <option value="3" <?php if($search_shop_toilet_access == '3') echo 'selected="selected"'; ?>>3</option>
  797. <option value="4" <?php if($search_shop_toilet_access == '4') echo 'selected="selected"'; ?>>4</option>
  798. <option value="5" <?php if($search_shop_toilet_access == '5') echo 'selected="selected"'; ?>>5</option>
  799. </select>
  800. </li>
  801. </ol>
  802. </fieldset>
  803.  
  804. <fieldset id="search_buttons">
  805. <button id="submit" name="submit" type="submit">Search</button>
  806. <button id="reset" name="reset" type="reset" ONCLICK="window.location.href='search.php'">Reset</button>
  807. </fieldset>
  808. </form>
  809. <?php // print_r($_GET); //SHOW THE SEARCHED data
  810.  
  811.  
  812. if(isset($_GET['submit'])) {
  813. if($numrows > 0) { ?>
  814. <div id="legend_total_results"><span>Found <?php echo $nr; ?> Coffeeshops</span></div>
  815. <?php }
  816. //print_r($_SERVER); // Useful server details
  817.  
  818. $paginationSort = "";
  819. ?>
  820. <?php $numrows = mysql_num_rows($result);
  821. if($numrows > 10) { ?>
  822. <div id="ribbon_search_wrapper">
  823. <div class="ribbon_wrapper_pg_top">
  824. <div class="ribbon-wrapper">
  825. <div class="ribbon-front">
  826. <?php echo $paginationDisplay;
  827. $paginationSort .= $_SERVER['PHP_SELF'] . '?s=final_total';
  828.  
  829. if(strlen($search_shop_name) > 0) {
  830. $paginationSort .= '&amp;search_shop_name=' . $search_shop_name;
  831. }
  832. if(strlen($search_shop_address) > 0) {
  833. $paginationSort .= '&amp;search_shop_address=' . $search_shop_address;
  834. }
  835. if($search_open_now == "on") {
  836. $paginationSort .= '&amp;search_open_now=' . $search_open_now;
  837. }
  838. if($search_total_rating > 0) {
  839. $paginationSort .= '&amp;search_total_rating=' . $search_total_rating;
  840. }
  841. if($vapo == "yes")
  842. {
  843. $paginationSort .= '&amp;vapo=' . $vapo;
  844. }
  845. if($pool == "yes") {
  846. $paginationSort .= '&amp;pool=' . $pool;
  847. }
  848. if($snacks == "yes") {
  849. $paginationSort .= '&amp;snacks=' . $snacks;
  850. }
  851. if($daccess == "yes") {
  852. $paginationSort .= '&amp;daccess=' . $daccess;
  853. }
  854. if($tv == "yes") {
  855. $paginationSort .= '&amp;tv=' . $tv;
  856. }
  857. if($games == "yes") {
  858. $paginationSort .= '&amp;games=' . $games;
  859. }
  860. if($cat == "yes") {
  861. $paginationSort .= '&amp;cat=' . $cat;
  862. }
  863. if($internet == "yes") {
  864. $paginationSort .= '&amp;internet=' . $internet;
  865. }
  866. if($spacecake == "yes") {
  867. $paginationSort .= '&amp;spacecake=' . $spacecake;
  868. }
  869. if($bud == "yes") {
  870. $paginationSort .= '&amp;bud=' . $bud;
  871. }
  872. if($booze == "yes") {
  873. $paginationSort .= '&amp;booze=' . $booze;
  874. }
  875. if($search_shop_comfort > 0) {
  876. $paginationSort .= '&amp;search_shop_comfort=' . $search_shop_comfort;
  877. }
  878. if($search_shop_service > 0) {
  879. $paginationSort .= '&amp;search_shop_service=' . $search_shop_service;
  880. }
  881. if($search_shop_ambience > 0) {
  882. $paginationSort .= '&amp;search_shop_ambience=' . $search_shop_ambience;
  883. }
  884. if($search_shop_friendliness > 0) {
  885. $paginationSort .= '&amp;search_shop_friendliness=' . $search_shop_friendliness;
  886. }
  887. if($search_shop_spacious > 0) {
  888. $paginationSort .= '&amp;search_shop_spacious=' . $search_shop_spacious;
  889. }
  890. if($search_shop_experience > 0) {
  891. $paginationSort .= '&amp;search_shop_experience=' . $search_shop_experience;
  892. }
  893. if($search_shop_bud_quality > 0) {
  894. $paginationSort .= '&amp;search_shop_bud_quality=' . $search_shop_bud_quality;
  895. }
  896. if($search_shop_bud_price > 0) {
  897. $paginationSort .= '&amp;search_shop_bud_price=' . $search_shop_bud_price;
  898. }
  899. if($search_shop_drink_price > 0) {
  900. $paginationSort .= '&amp;search_shop_drink_price=' . $search_shop_drink_price;
  901. }
  902. if($search_shop_space_cake > 0) {
  903. $paginationSort .= '&amp;search_shop_space_cake=' . $search_shop_space_cake;
  904. }
  905. if($search_shop_accessibility > 0) {
  906. $paginationSort .= '&amp;search_shop_accessibility=' . $search_shop_accessibility;
  907. }
  908. if($search_shop_toilet_access > 0) {
  909. $paginationSort .= '&amp;search_shop_toilet_access=' . $search_shop_toilet_access;
  910. }
  911. ?>
  912. <span class="sort_options"><a class="<?php echo $sort_by == 'shop_id' ? 'sortColumn' : ''; ?>" href="<?php echo $paginationSort . '&amp;s=shop_name&amp;d='.$reverse_direction.'&amp;submit'; ?>">Title</a>
  913. <?php echo $sort_by == 'shop_name' ? $sort_arrow : ''; ?>
  914. <a class="<?php echo $sort_by == 'shop_id' ? 'sortColumn' : ''; ?>" href="<?php echo $paginationSort . '&amp;d=' . $reverse_direction . '&amp;submit';?>">Rating Total</a>
  915. <?php echo $sort_by == 'final_total' ? $sort_arrow : ''; ?></span>
  916. </div>
  917. <div class="ribbon-edge-topleft"></div>
  918. <div class="ribbon-edge-topright"></div>
  919. <div class="ribbon-edge-bottomleft"></div>
  920. <div class="ribbon-edge-bottomright"></div>
  921. <div class="ribbon-back-left"></div>
  922. <div class="ribbon-back-right"></div>
  923. </div>
  924. </div>
  925. </div>
  926. <?php }?>
  927.  
  928. <?php foreach($results as $row) { ?>
  929. <div class="wrapper_coffeeshop">
  930. <div class="shop_top"><h1><?php echo "<a href='coffeeshop.php?shop_id=".$row["shop_id"]."'>". $row["shop_title"] ." ". $row["shop_name"]."</a>"; ?></h1></div>
  931. <section class="coffeeshop">
  932. <article class="shop_details">
  933. <?php if(file_exists("img/photos/".$row["shop_img"] . ".jpg")) {
  934. echo "<a href='coffeeshop.php?shop_id=" . $row["shop_id"]. "'>" . "<img class ='shopimg' src='img/shops/" . $row["shop_img"] . ".jpg' alt='".$row['shop_title'] ." ". $row['shop_name']."' /></a>";
  935. } else { $row["shop_img"] = "shop_placeholder";
  936. echo "<a href='coffeeshop.php?shop_id=" . $row["shop_id"]. "'>" . "<img class ='shopimg' src='img/placeholder/" . $row["shop_img"] . ".png' alt='".$row['shop_title'] ." ". $row['shop_name']."' /></a>";
  937. } // Checks if there is an image for that shop otherwise sets a placeholder ?>
  938. <address><?php echo $row["shop_number"] . ' ' . $row["shop_location"] . ', ' . $row["shop_district"] . ' ' . $row["shop_postcode"]; ?></address>
  939. <p><?php echo $row["shop_description"]; ?></p>
  940.  
  941. <article class="openclose">
  942. <h2>Open - Close</h2>
  943. <?php $open = $row["shop_open"]; $shop_open = strtotime($open);
  944. $close = $row["shop_close"]; $shop_close = strtotime($close); ?>
  945. <time><?php echo date('H\:i', $shop_open); ?></time> - <time><?php echo date('H\:i', $shop_close); ?></time>
  946. </article>
  947.  
  948. <article class="shoptotal">
  949. <?php $shop_id = $row['shop_id'];
  950. echo pullRatingTotal($shop_id,true,true,true); ?>
  951. </article>
  952. </article>
  953.  
  954. <article class="services">
  955. <h1>Services</h1>
  956. <div class="services_img_wrapper">
  957. <?php echo "<img src='img/icons/vapo_" . $row["services_vapo"] . ".png' width='50' height='50' alt='Vaporizer' title='Vaporizer '/>";
  958. echo "<img src='img/icons/pool_" . $row["services_pool"] . ".png' width='50' height='50' alt='Pool Table' title='Pool Table' />";
  959. echo "<img src='img/icons/snacks_" . $row["services_snacks"] . ".png' width='50' height='50' alt='Snacks' title='Snacks' />";
  960. echo "<img src='img/icons/disabled_" . $row["services_disabled"] . ".png' width='50' height='50' alt='Wheelchair access' title='Wheelchair access'/>";
  961. echo "<img src='img/icons/cat_" . $row["services_cat"] . ".png' width='50' height='50' alt='Cat' title='Cat' />";
  962. echo "<img src='img/icons/tv_" . $row["services_tv"] . ".png' width='50' height='50' alt='Television' title='Television'/>";?>
  963. </div>
  964. </article>
  965. </section>
  966. <div class="shop_bottom"></div>
  967. </div>
  968. <?php // close while //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  969. /////////////////////////////////////////////////////// END QUERY THE MEMBER DATA & Build the Output Section //////////////////////////// ?>
  970. <?php }
  971.  
  972. $numrows = mysql_num_rows($result);
  973. if($numrows > 10) { ?>
  974. <div id="ribbon_search_wrapper_bottom">
  975. <div class="ribbon_wrapper_pg_bot">
  976. <div class="ribbon-wrapper">
  977. <div class="ribbon-front">
  978. <?php echo $paginationDisplay; ?>
  979. <span class="sort_options"><a class="<?php echo $sort_by == 'shop_id' ? 'sortColumn' : ''; ?>" href="<?php echo $paginationSort . '&amp;s=shop_name&amp;d='.$reverse_direction.'&amp;submit'; ?>">Title</a>
  980. <?php echo $sort_by == 'shop_name' ? $sort_arrow : ''; ?>
  981. <a class="<?php echo $sort_by == 'shop_id' ? 'sortColumn' : ''; ?>" href="<?php echo $paginationSort . '&amp;d=' . $reverse_direction . '&amp;submit';?>">Rating Total</a>
  982. <?php echo $sort_by == 'final_total' ? $sort_arrow : ''; ?></span>
  983. </div>
  984. <div class="ribbon-edge-topleft"></div>
  985. <div class="ribbon-edge-topright"></div>
  986. <div class="ribbon-edge-bottomleft"></div>
  987. <div class="ribbon-edge-bottomright"></div>
  988. <div class="ribbon-back-left"></div>
  989. <div class="ribbon-back-right"></div>
  990. </div>
  991. </div>
  992. <?php }
  993. }
  994. mysql_close($connect);
  995.  
  996. $status = explode(' ', mysql_stat($connect));
  997. print_r($status);
  998.  
  999. //print_r(mysql_ping()); connect is dead and gives an Error if mysql_close of connection
  1000. ?>
  1001. </section>
  1002.  
  1003. <footer>
  1004. <?php require_once('inc/footer.php'); ?>
  1005. </footer>
  1006. </div>
  1007. </body>
  1008. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement