Search criteria:
\n"); print("
"); $connection = pg_connect("localhost", "5432", $database_name); if($connection) { $multiple = 0; $query = "SELECT * FROM member WHERE "; if($category || $wordsearch || $contactsearch) { if($category) { $query .= "category = '" . $category . "'"; $multiple = 1; } if($wordsearch) { if($multiple) $query .= " AND "; switch($wordoption) { case "start": $query .= "upper(company) LIKE upper('" . $wordsearch . "%')"; break; case "contain": $query .= "upper(company) LIKE upper('%" . $wordsearch . "%')"; break; case "end": $query .= "upper(company) LIKE upper('%" . $wordsearch . "')"; break; } $multiple = 1; } if($contactsearch) { if($multiple) $query .= " AND "; switch($contactoption) { case "start": $query .= "upper(contact) LIKE upper('" . $contactsearch . "%')"; break; case "contain": $query .= "upper(contact) LIKE upper('%" . $contactsearch . "%')"; break; case "end": $query .= "upper(contact) LIKE upper('%" . $contactsearch . "')"; break; } } } else $query .= "category is not null"; $query .= " ORDER BY category,company,contact"; // print("

query: " . $query . "

\n"); $result = pg_exec($connection, $query); if($result) { $total_rows = pg_numrows($result); if($linesperpage <= 0) $linesperpage = $total_rows; $total_pages = (($total_rows - 1) / $linesperpage) + 1; settype($total_pages, "integer"); switch($bsact) { case " < ": $begin -= $linesperpage; if($begin < 0) { $begin = 0; $page = 1; } else $page--; break; case " > ": $begin += $linesperpage; if($begin > ($total_rows - $linesperpage)) { $begin = $total_rows - $linesperpage; $page = $total_pages; } else $page++; break; case ">>": $begin = $total_rows - $linesperpage; $page = $total_pages; break; default: $begin = 0; $page = 1; break; } $last_row = $begin + $linesperpage; if($last_row > $total_rows) $last_row = $total_rows; print("\n"); print("\n"); print("\n"); print("\n"); print("\n"); print("\n"); print("\n"); print("\n"); // $url_args = "&begin=$begin&page=$page&category="; // $url_args .= urlencode($category); // $url_args .= "&wordsearch=$wordsearch&wordoption=$wordoption&contactsearch=$contactsearch&contactoption=$contactoption"; print(""); if($total_rows > $linesperpage && $begin > 0) { print("\n"); // print("\n"); } else print("\n"); print("\n"); if($total_rows > $linesperpage && $begin != ($total_rows - $linesperpage)) { print("\n"); // print("\n"); } else print("\n"); print("
\n"); print("First\n"); // print("PrevPage $page of $total_pages \">\n"); print(">\">Next\n"); // print("Last

\n"); print("\n"); print("\n"); for($row = $begin, $row_style=0; $row < $last_row; $row++, $row_style++) { $row_data = pg_fetch_row($result, $row); if($row_data[0] != $previous_category) { if(isset($previous_category)) print("\n"); $previous_category = $row_data[0]; print("\n"); $row_style = 0; } if($row_style & 1) print(""); else print(""); print(""); print(""); print("\n"); if($row_style & 1) print(""); else print(""); print(""); print(""); print("\n"); if($row_style & 1) print(""); else print(""); print(""); print(""); print("\n"); } print("
 
$row_data[0]
"); if($row_data[1]) { print($row_data[1]); if($row_data[2]) print(" (" . $row_data[2] . ")"); } else { if($row_data[2]) print($row_data[2]); else print(" "); } print(""); if($row_data[8] && $row_data[9]) print($row_data[8] . ":" . $row_data[9]); else print(" "); print("
"); if($row_data[3]) print($row_data[3]); else print(" "); print(""); if($row_data[10] && $row_data[11]) print($row_data[10] . ":" . $row_data[11]); else print(" "); print("
"); if($row_data[4] && $row_data[5] && $row_data[6]) print($row_data[4] . "," . $row_data[5] . " " . $row_data[6]); else print(" "); if($row_data[7]) print("-" . $row_data[7]); print(""); if($row_data[12] && $row_data[13]) print($row_data[12] . ":" . $row_data[13]); else print(" "); print("
\n"); pg_freeresult($result); } else print("Search criteria yield no results.
\n"); pg_close($connection); print("

\n"); } ?>