RE: [PHP-DB] Search Query
| From: | Cami | Date: | Fri, 27 Jul 2001 14:23:35 +0000 |
| Subject: | RE: [PHP-DB] Search Query | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-10833@lists.php.net to get a copy of this message | ||
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:sf@mnetsys.com]
Sent: Friday, July 27, 2001 3:04 PM
To: php-db@lists.php.net
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: php-db-unsubscribe@lists.php.net
For additional commands, e-mail: php-db-help@lists.php.net
To contact the list administrators, e-mail: php-list-admin@lists.php.net