PHP Classes

File: try2.php

Recommend this page to a friend!
  Classes of Craig Heydenburg   better_field_search   try2.php   Download  
File: try2.php
Role: Example script
Content type: text/plain
Description: second example
Class: better_field_search
Generalized, flexible class to search a mysql DB
Author: By
Last change:
Date: 21 years ago
Size: 1,502 bytes
 

Contents

Class file image Download
<?
// this is an exmple showing the use of the get_field_names function and
// its usefulness.
/*
This is a sample of how to implement the class.search.php class.
The class was originally written by
Sujith Nair [sujith_77@hotmail.com]
On September 12, 2001

greatly modified and enhanced by
Craig Heydenburg [craigh@mac.com]
May 14, 2002
*/
require ("class.search.php");

// change the information below to suit your needs
$try=new search_fields("hostname","username","password","dbname");
$table="tablename";
// end

if ($submit<>"search") {
?>
<HTML>
<HEAD>
<TITLE>Search</TITLE>
</HEAD>
<BODY style='font-family:Arial,Helvetica,San-Serif;'>
<B>Search</B><BR>
Select the fields you would like to search in and display:<BR>
<form action="<? echo basename($PHP_SELF) ?>" method="post">
<? while (list($k,$v)=each($try->get_field_names($table))) {
        print (
"<INPUT TYPE='checkbox' NAME='cols[".$k."]' value='".$v."'> ".$v."<BR>");
    }
?>
<BR>
Enter words or title: <INPUT TYPE="TEXT" NAME="terms">
<INPUT TYPE="hidden" Name="submit" value="search">
<button type="submit" name="sub_button">Search</button></FORM>
</BODY>
</HTML>

<?
} else {
?>
<HTML><HEAD><TITLE>Search Results</TITLE></HEAD>
<BODY style='font-family:Arial,Helvetica,San-Serif;'>
<?
$try
->make_str($table,$terms,$cols);

// Match the keywords and display the result
$try->showresult();
?>
<BR><BR><A HREF="<? echo basename($PHP_SELF) ?>">Search Again</A>
</BODY>
</HTML>
<?
}
?>