I'm trying to get a search script running so that users can choose the field to search (from a list of 5), then type in the data to search for, and get the results displayed in a table. I've been trying for ages and cant get anything to work. Heres the script I'm using to enter data to the db, so you can see the fields, etc:
As an afterthought, is there any way to get the above script to refresh the table when the submit button is clicked, instead of confirming that the data has been entered??
I know its a lot to ask, but I am really banging my head off a wall now.
Pha3dr0n
PHP Code:
<?php
if ($submit):
$dbcnx = @mysql_connect( "xxxx", "xxxx", "xxxx");
mysql_select_db("contacts");
$sql = "INSERT INTO admin_contacts SET " .
"forename='$forename', " .
"surname='$surname', " .
"category='$category', " .
"address1='$address1', " .
"address2='$address2', " .
"address3='$address3', " .
"address4='$address4', " .
"postcode='$postcode', " .
"homephone='$homephone', " .
"mobile='$mobile', " .
"fax='$fax', " .
"email='$email', " .
"title='$title', " .
"shows='$shows', " .
"sex='$sex'";
if (mysql_query($sql)) { echo("<P>New Record Added</P>");
} else {
echo("<P>Error adding new record: " .
mysql_error() . "</P>"); }
?>
<P><A HREF="<?php echo($PHP_SELF); ?>">Add another record</A></P>
<?php else: // Enter another record?>
<FORM ACTION="<?php echo($PHP_SELF); ?>" METHOD=POST>
<P>Please enter your information below<BR>
Name:
<INPUT TYPE=TEXT NAME="forename" SIZE=22MAXLENGTH=100>
<input type=TEXT name="surname" size=30MAXLENGTH=100>
<br>
Category:
<select name="category">
<option value="Committee">Committee
<option value="Business">Business
<option value="Mailshot">Mailshot
<option value="Vip">VIP
<option value="Cast">Cast
<option value="Fans">Fans
</select>
<br>
Address:
<input type=TEXT name="address1" size=44MAXLENGTH=100>
<br>
Address2:
<input type=TEXT name="address2" size=44MAXLENGTH=100>
<br>
Address3:
<input type=TEXT name="address3" size=44MAXLENGTH=100>
<br>
Address4:
<input type=TEXT name="address4" size=44MAXLENGTH=100>
<br>
Postcode:
<input type=TEXT name="postcode" size=44MAXLENGTH=100>
<br>
Home Phone:
<input type=TEXT name="homephone" size=44MAXLENGTH=100>
<br>
Mobile:
<input type=TEXT name="mobile" size=28MAXLENGTH=100>
<br>
Fax:
<input type=TEXT name="fax" size=44MAXLENGTH=100>
<br>
Email:
<input type=TEXT name="email" size=44MAXLENGTH=100>
<br>
Title:
<input type=TEXT name="title" size=44MAXLENGTH=100>
<br>
Shows:
<input type=TEXT name="shows" size=44MAXLENGTH=100>
<br>
Sex:
<select name="sex">
<option value="Male">Male
<option value="Female">Female
</select>
<br>
<INPUT TYPE=SUBMIT NAME="submit" VALUE="SUBMIT">
</P>
</FORM>
<?php endif; ?>
I know its a lot to ask, but I am really banging my head off a wall now.
Pha3dr0n
Comment