Well I would like to thank everyone that helped me create php script to
search a MySQL database using a form to pass the contents of the textbox to
the php script as a variable in the search string.  Here is the final script
if anyone wants to use it, update, enhance feel free just send me a copy so
I can update my own.  Thanks again eveyone!!
jason
enj0i.com

<?php

#################################################
#  phpMySearch v. 0.1.3 - MySQL DB Search Form
#
#  Author:  Jason Gerfen
#  Email:  [EMAIL PROTECTED]
#  Site:  http://enj0i.com
#  Date:  10.26.2001
#################################################
#  Script functions:
#   * Connect to MySQL DB using PHP
# * Uses form to pass variable as a search sting.
# * Displays results of search.
#################################################
#  Requirments:
# * PHP & MySQL
#################################################
#  Copyright:
#  This script can be redistributed as long as the header
#  remains intact.  If you make changes to this script, or
#  enhancements please send me a copy so I may update
#  my own script.  Thanks, Jason
#################################################
#  Instructions:
#   * Create form with form names corresponding
#     to the table names in your database.
# *  Change connection parameters for your
#     database host, username, password &
#     database name. (see comments in script)
# *  Change table names to match tables in your
#     databse.
#################################################

/* Change db_hostname, db_username & db_password for your database
connection and login */
mysql_connect ("db_hostname", "db_username", "db_password") or die("Couldn't
connect!");

/* Change db_name to match your database name */
mysql_select_db ("db_name") or die("Couldn't select database");

/* Change db_tablename to match tables you want to search */
if ($db_tablename == "")
{$db_tablename = '%';}

/* Change db_tablename to match tables in database */
$result = mysql_query ("SELECT * FROM db_tablename
                         WHERE fname LIKE '%$db_table%'");

if ($row = mysql_fetch_array($result)) {

/* Change all instances of db_table to match your db table structure */
do {
  PRINT "Your search results: <br><br>";
  PRINT "<b>db_table:     </b> ";
  print $row["db_table"];
  print ("<br>");
  PRINT "<b>db_table:     </b> ";
  print $row["db_table"];
  print ("<br>");
  PRINT "<b>db_table:     </b> ";
  print $row["db_table"];
  print ("<br>");
  PRINT "<b>db_table:     </b> ";
  print $row["db_table"];
  print ("<br>");
  PRINT "<b>db_table:     </b> ";
  print $row["db_table"];
  print ("<br>");
  PRINT "<b>db_table:     </b> ";
  print $row["db_table"];
  print ("<br>");
  PRINT "<b>db_table:     </b> ";
  print $row["db_table"];
  print ("<br>");
  PRINT "<b>db_table:     </b> ";
  print $row["db_table"];
  print ("<br>");
  PRINT "<b>db_table:     </b> ";
  print $row["db_table"];
  print ("<br>");
  PRINT "<b>db_table:     </b> ";
  print $row["db_table"];
  print ("<br>");
  PRINT "<b>db_table:     </b> ";
  print $row["db_table"];
  print ("<br>");
  PRINT "<b>db_table:     </b> ";
  print $row["db_table"];
  print ("<br>");
  PRINT "<b>db_table:     </b> ";
  print $row["db_table"];
  print ("<br>");
  PRINT "<b>db_table:     </b> ";
  print $row["db_table"];
  print ("<br>");
  print ("<hr>");
} while($row = mysql_fetch_array($result));
} else {print "Sorry, no records were found!";}

?>



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to