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.

241 lines
7.4 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_arg = "&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=3></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=3>&nbsp</td></tr>\n");
  134. $previous_category = $row_data[0];
  135. print("<tr class=header><th align=center colspan=3>$row_data[0]</th></tr>\n");
  136. // print("<tr><td colspan=3></td></tr>\n");
  137. $row_style = 0;
  138. }
  139. // else print("<tr><td colspan=3><hr></td></tr>\n");
  140. if($row_data[1])
  141. {
  142. if($row_style & 1) print("<tr class=darkrow>");
  143. else print("<tr class=lightrow>");
  144. print("<td align=left colspan=2>");
  145. print($row_data[1]);
  146. print("</td><td align=right colspan=1>");
  147. if($row_data[2]) print($row_data[2]);
  148. }
  149. else
  150. {
  151. if($row_style & 1) print("<tr class=darkrow>");
  152. else print("<tr class=lightrow>");
  153. print("<td align=left colspan=3>");
  154. if($row_data[2]) print($row_data[2]);
  155. }
  156. print("</td></tr>\n");
  157. if($row_style & 1) print("<tr class=darkrow>");
  158. else print("<tr class=lightrow>");
  159. print("<td align=left colspan=2 width=\"60%\">");
  160. if($row_data[3]) print($row_data[3]);
  161. print("</td><td align=right colspan=1 width=\"40%\">");
  162. if($row_data[4]) print("$row_data[4], ");
  163. if($row_data[5]) print("$row_data[5]");
  164. if($row_data[6]) print(" $row_data[6]");
  165. if($row_data[7]) print("-$row_data[7]");
  166. print("</td></tr>\n");
  167. $num_phones = (pg_numfields($result) - 8) / 2;
  168. for($phone = 0, $field = 8; $phone < $num_phones; $phone++, $field += 2)
  169. {
  170. if(($phone % 3) == 0)
  171. {
  172. if($row_style & 1) print("<tr class=darkrow>");
  173. else print("<tr class=lightrow>");
  174. }
  175. print("<td");
  176. switch($phone % 3)
  177. {
  178. case 0:
  179. print(" align=left");
  180. break;
  181. case 1:
  182. if(($phone+1) == $num_phones)
  183. print(" align=right colspan=2");
  184. else print(" align=middle");
  185. break;
  186. case 2:
  187. print(" align=right");
  188. break;
  189. }
  190. print(">");
  191. if($row_data[$field] && $row_data[$field+1])
  192. print($row_data[$field] . " : " . $row_data[$field+1]);
  193. else print("&nbsp");
  194. print("</td>");
  195. if(($phone % 3) == 2) print("</tr>\n");
  196. }
  197. }
  198. print("</table>\n");
  199. pg_freeresult($result);
  200. }
  201. else print("Search criteria yield no results.<br>\n");
  202. pg_close($connection);
  203. print("</form>\n");
  204. }
  205. ?>
  206. </body>
  207. </html>