You'll need three pages:
in the first one put
<form method=post action=secondpage.php3>
<input type="text" name="contactname">
submit it to the second page where you have:
$sql = "select * from contacts where (FirstName like '%$contactname%' or
LastName like '%$contactname%') and Active='yes' order by ID";
$result = mysql_query($sql);
$numrows = mysql_num_rows($result);
if ($numrows>0) {
while ($list = mysql_fetch_array($result)) {
echo "<a
href=\"thirdpage.php3?ID=".$list["ContactID"].">".$list["FirstName"]."
".$list["LastName"]."</a><br>";
}}
And in the third page:
$sql = "select * from contacts where ContactID='$ID'";
$result = mysql_query($sql);
$numrows = mysql_num_rows($result);
if ($numrows>0) {
while ($list = mysql_fetch_array($result)) {
just echo the details that you need.
}}
Hope this is what you want
Kind Regards,
Cami
-----Original Message-----
From: Steve Fitzgerald [mailto:[EMAIL PROTECTED]]
Sent: Friday, July 27, 2001 3:04 PM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] Search Query
I'm trying to build a search query that will allow users to search (via a
textbox) different tables.
For example, I have a table name contacts with columns ContactID, FirstName,
LastName, and Active. I want to be able to search for John Smith or Smith
where Active=yes (as opposed to Active=no which would indicate the contact
is no longer active). I would then like to have the result(s) to have a link
to their respective ContactID.
I don't think this is that difficult, but I'm having difficulty applying the
SELECT statement with the text box.
Any help would be greatly appreciated.
Steve Fitzgerald
--
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]
--
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]