|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
PHP Database Search
I am using a code sample from this site to search my database, Code is as follows
Search for a Client</h3> <? mysql_select_db($database_cielo_dbcon, $cielo_dbcon);?> <? //You should now this but be sure to connect to your database or this is useless. :/ if ($EmailAddress == "EmailAddress") {$EmailAddress = '%';} // $user and $passwd are the two column names I used. Change this to fit your database $result = mysql_query ("SELECT * FROM clients WHERE EmailAddress LIKE '%$EmailAddress%' "); if ($row = mysql_fetch_array($result)) { do { PRINT "<b>Client Id: </b> "; print $row["ClientId"]; print (" "); print ("<br>"); PRINT "<b>First Name: </b> "; print $row["FirstName"]; print ("<p>"); PRINT "<b>Last Name: </b> "; print $row["LastName"]; print ("<p>"); PRINT "<b>Address: </b> "; print $row["Address"]; print ("<p>"); PRINT "<b>City: </b> "; print $row["City"]; print ("<p>"); PRINT "<b>State: </b> "; print $row["State"]; print ("<p>"); PRINT "<b>Postal Code: </b> "; print $row["PostalCode"]; print ("<p>"); PRINT "<b>Phone Number: </b> "; print $row["PhoneNumber"]; print ("<p>"); PRINT "<b>Email Address: </b> "; print $row["EmailAddress"]; print ("<p>"); PRINT "<b>Notes: </b> "; print $row["Notes"]; print ("<p>"); } while($row = mysql_fetch_array($result)); } else {print "Sorry, no records were found!";} //The end result prints the username / passwd / firstname / lastname / ID / email //you will have to change these fields also to fit your needs ?> But when I enter an email address to search it returns all email addresses in the database not just the one I was searching for. Please Help PHP NEWBIE Cliff |
|
#2
|
|||
|
|||
|
RE: PHP Database Search
hmmm...maybe globals are off...change:
WHERE EmailAddress LIKE '%$EmailAddress%' to: WHERE EmailAddress LIKE '%$_POST[EmailAddress]%' |
|
#3
|
|||
|
|||
|
RE: PHP Database Search
Still does the same thing.?????
|
|
#4
|
|||
|
|||
|
RE: PHP Database Search
change:
$result = mysql_query ("SELECT * FROM clients WHERE EmailAddress LIKE '%$EmailAddress%' "); into : $query = "SELECT * FROM clients WHERE EmailAddress LIKE '%$EmailAddress%' "; echo $query; $result = mysql_query ($query); then show us what the query ends up looking like.... |
|
#5
|
|||
|
|||
|
RE: PHP Database Search
Ok Matt, I did what you said and entered the query mac which should have returned no results at all and this is what I got....
Keep in mind this is the only entry in the database at this time..... SELECT * FROM clients WHERE EmailAddress LIKE '%%' Client Id: 1 First Name: Michael Last Name: Dailey Address: 1180 Some Fake Ave City: Las Vegas State: NV Postal Code: 89123 Phone Number: ***-**** Email Address: mike@futurescapedesign.com |
|
#6
|
|||
|
|||
|
RE: PHP Database Search
Show me the form you use to enter the email address into....
|
|
#7
|
|||
|
|||
|
RE: PHP Database Search
Here is the form....
<form method=post action="search.php"> <font size="2" face="Geneva, Arial, Helvetica, sans-serif"> <div align="center">Search For: </div> </font> <div align="center"><font size="2"></font></div> <font size="2"> <p align="center"><font face="Geneva, Arial, Helvetica, sans-serif"> Email Address: <input type=text name=user size=25 maxlength=50> </font> </font> <p align="center"> <font size="2" face="Geneva, Arial, Helvetica, sans-serif"> <input type=submit> </font> </form> Youe can see it at.. http://cielosalonandspa.com/find.php |
|
#8
|
|||
|
|||
|
RE: PHP Database Search
Email
Address: <input type=text name=user size=25 maxlength=50> There's the problem...you need to name that input EmailAddress not user... |
![]() |
| Viewing: Codewalkers Forums > Other Technologies > Database Help > PHP Database Search |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|
|