Olive Branch MS Chamber of Commerce (circa Oct 1999)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

228 lines
6.9 KiB

  1. <html>
  2. <head>
  3. <title>Olive Branch, MS</title>
  4. </head>
  5. <link rel=stylesheet href=/styles/basic.css type=text/css>
  6. <body>
  7. <?
  8. // $linesperpage = 10;
  9. $database_name = "olivebranch";
  10. //print("<b>Search criteria:</b><br>\n");
  11. print("<form method=\"post\" action=\"bsearchresult.php3\">");
  12. $connection = pg_connect("localhost", "5432", $database_name);
  13. if($connection)
  14. {
  15. $multiple = 0;
  16. $query = "SELECT * FROM member WHERE ";
  17. if($category || $wordsearch || $contactsearch)
  18. {
  19. if($category)
  20. {
  21. $query .= "category = '" . $category . "'";
  22. $multiple = 1;
  23. }
  24. if($wordsearch)
  25. {
  26. if($multiple) $query .= " AND ";
  27. switch($wordoption)
  28. {
  29. case "start":
  30. $query .= "upper(company) LIKE upper('" . $wordsearch . "%')";
  31. break;
  32. case "contain":
  33. $query .= "upper(company) LIKE upper('%" . $wordsearch . "%')";
  34. break;
  35. case "end":
  36. $query .= "upper(company) LIKE upper('%" . $wordsearch . "')";
  37. break;
  38. }
  39. $multiple = 1;
  40. }
  41. if($contactsearch)
  42. {
  43. if($multiple) $query .= " AND ";
  44. switch($contactoption)
  45. {
  46. case "start":
  47. $query .= "upper(contact) LIKE upper('" . $contactsearch . "%')";
  48. break;
  49. case "contain":
  50. $query .= "upper(contact) LIKE upper('%" . $contactsearch . "%')";
  51. break;
  52. case "end":
  53. $query .= "upper(contact) LIKE upper('%" . $contactsearch . "')";
  54. break;
  55. }
  56. }
  57. }
  58. else $query .= "category is not null";
  59. $query .= " ORDER BY category,company,contact";
  60. // print("<p><b>query:</b> " . $query . "<p>\n");
  61. $result = pg_exec($connection, $query);
  62. if($result)
  63. {
  64. $total_rows = pg_numrows($result);
  65. if($linesperpage <= 0) $linesperpage = $total_rows;
  66. $total_pages = (($total_rows - 1) / $linesperpage) + 1;
  67. settype($total_pages, "integer");
  68. switch($bsact)
  69. {
  70. case " < ":
  71. $begin -= $linesperpage;
  72. if($begin < 0) { $begin = 0; $page = 1; }
  73. else $page--;
  74. break;
  75. case " > ":
  76. $begin += $linesperpage;
  77. if($begin > ($total_rows - $linesperpage))
  78. {
  79. $begin = $total_rows - $linesperpage;
  80. $page = $total_pages;
  81. }
  82. else $page++;
  83. break;
  84. case ">>":
  85. $begin = $total_rows - $linesperpage;
  86. $page = $total_pages;
  87. break;
  88. default:
  89. $begin = 0;
  90. $page = 1;
  91. break;
  92. }
  93. $last_row = $begin + $linesperpage;
  94. if($last_row > $total_rows) $last_row = $total_rows;
  95. print("<input type=\"hidden\" name=\"linesperpage\" value=\"" . $linesperpage . "\">\n");
  96. print("<input type=\"hidden\" name=\"begin\" value=\"" . $begin . "\">\n");
  97. print("<input type=\"hidden\" name=\"page\" value=\"" . $page . "\">\n");
  98. print("<input type=\"hidden\" name=\"category\" value=\"" . $category . "\">\n");
  99. print("<input type=\"hidden\" name=\"wordsearch\" value=\"" . $wordsearch . "\">\n");
  100. print("<input type=\"hidden\" name=\"wordoption\" value=\"" . $wordoption . "\">\n");
  101. print("<input type=\"hidden\" name=\"contactsearch\" value=\"" . $contactsearch . "\">\n");
  102. print("<input type=\"hidden\" name=\"contactoption\" value=\"" . $contactoption . "\">\n");
  103. // $url_args = "&begin=$begin&page=$page&category=";
  104. // $url_args .= urlencode($category);
  105. // $url_args .= "&wordsearch=$wordsearch&wordoption=$wordoption&contactsearch=$contactsearch&contactoption=$contactoption";
  106. print("<table border=0 width=\"450\" cellspacing=0 cellpadding=0><tr>");
  107. if($total_rows > $linesperpage && $begin > 0)
  108. {
  109. print("<td align=left width=\"100\"><input type=\"submit\" name=\"bsact\" value=\"<<\">\n");
  110. print("<input type=\"submit\" name=\"bsact\" value=\" < \"></td>\n");
  111. // print("<td align=left width=\"100\"><a href=\"bsearchresult.php3?bsact=first" . $url_args . "\">First</a>\n");
  112. // print("<a href=\"bsearchresult.php3?bsact=prev" . $url_args . "\">Prev</a></td>\n");
  113. }
  114. else print("<td width=\"100\"></td>\n");
  115. print("<th align=center><b>Page $page of $total_pages</b></th>\n");
  116. if($total_rows > $linesperpage && $begin != ($total_rows - $linesperpage))
  117. {
  118. print("<td align=right width=\"100\"><input type=\"submit\" name=\"bsact\" value=\" > \">\n");
  119. print("<input type=\"submit\" name=\"bsact\" value=\">>\"></td>\n");
  120. // print("<td align=right width=\"100\"><a href=\"bsearchresult.php3?bsact=next" . $url_args . "\">Next</a>\n");
  121. // print("<a href=\"bsearchresult.php3?bsact=last" . $url_args . "\">Last</a></td>\n");
  122. }
  123. else print("<th width=\"100\"></th>\n");
  124. print("</tr></table><br>\n");
  125. print("<table border=0 width=450 cellspacing=0 cellpadding=0>\n");
  126. print("<tr><td colspan=2></td></tr>\n");
  127. for($row = $begin, $row_style=0; $row < $last_row; $row++, $row_style++)
  128. {
  129. $row_data = pg_fetch_row($result, $row);
  130. if($row_data[0] != $previous_category)
  131. {
  132. if(isset($previous_category))
  133. print("<tr><td colspan=2>&nbsp</td></tr>\n");
  134. $previous_category = $row_data[0];
  135. print("<tr class=header><th align=center colspan=2>$row_data[0]</th></tr>\n");
  136. $row_style = 0;
  137. }
  138. if($row_style & 1) print("<tr class=darkrow>");
  139. else print("<tr class=lightrow>");
  140. print("<td align=left>");
  141. if($row_data[1])
  142. {
  143. print($row_data[1]);
  144. if($row_data[2]) print(" (" . $row_data[2] . ")");
  145. }
  146. else
  147. {
  148. if($row_data[2]) print($row_data[2]);
  149. else print("&nbsp");
  150. }
  151. print("</td>");
  152. print("<td align=right>");
  153. if($row_data[8] && $row_data[9]) print($row_data[8] . ":" . $row_data[9]);
  154. else print("&nbsp");
  155. print("</td>");
  156. print("</tr>\n");
  157. if($row_style & 1) print("<tr class=darkrow>");
  158. else print("<tr class=lightrow>");
  159. print("<td align=left>");
  160. if($row_data[3]) print($row_data[3]);
  161. else print("&nbsp");
  162. print("</td>");
  163. print("<td align=right>");
  164. if($row_data[10] && $row_data[11]) print($row_data[10] . ":" . $row_data[11]);
  165. else print("&nbsp");
  166. print("</td>");
  167. print("</tr>\n");
  168. if($row_style & 1) print("<tr class=darkrow>");
  169. else print("<tr class=lightrow>");
  170. print("<td align=left>");
  171. if($row_data[4] && $row_data[5] && $row_data[6])
  172. print($row_data[4] . "," . $row_data[5] . " " . $row_data[6]);
  173. else print("&nbsp");
  174. if($row_data[7]) print("-" . $row_data[7]);
  175. print("</td>");
  176. print("<td align=right>");
  177. if($row_data[12] && $row_data[13]) print($row_data[12] . ":" . $row_data[13]);
  178. else print("&nbsp");
  179. print("</td>");
  180. print("</tr>\n");
  181. }
  182. print("</table>\n");
  183. pg_freeresult($result);
  184. }
  185. else print("Search criteria yield no results.<br>\n");
  186. pg_close($connection);
  187. print("</form>\n");
  188. }
  189. ?>
  190. </body>
  191. </html>