![]() |
|
Welcome to the Computer Webmaster Gaming Console Graphics Forum forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact contact us. |
| |||||||
| PHP PHP for some can be one of the hardest website programming codes, so do you need help on your PHP script, if it is php4, php5 or lower this is the place for you for any PHP help. |
![]() |
| | LinkBack | Thread Tools | Display Modes |
| | #1 | ||
| This is very peculiar -- for some reason, I'm getting 6-8 results from each of these queries, although only one listing matches. I have a pair of forms on one page: <FORM> Search for lastname: ____________ [Submit] </FORM> <FORM> Search for email: ________________ [Submit] </FORM> This goes to a searchresults.php page: if ($searchname !== "") { $query="SELECT artistID,firstname,lastname,email,city,state,count ry from artists WHERE lastname='$searchname'"; $result=mysql_query($query) or die(mysql_error("Could not execute query.")); while($row = mysql_fetch_array($result)) { $alt_artistID = $row['artistID']; $alt_firstname = $row['firstname']; $alt_lastname= $row['lastname']; $alt_email = $row['email']; $alt_city = $row['city']; $alt_state = $row['state']; $alt_country = $row['country']; echo "<CENTER><HR>".$alt_artistID."<BR>" .$alt_firstname." ".$alt_lastname."</A><BR>" .$alt_email."<BR>" .$alt_city.", ".$alt_state." ".$alt_country."<BR> <A HREF=delete.php?aritstID=".$alt_artistID.">DELETE THIS LISTING?</A><BR></CENTER>"; } } The second section is identical except for: if ($searchemail !== "") { $query="SELECT artistID,firstname,lastname,email,city,state,count ry from artists WHERE email='$searchemail'"; etc... } I don't understand why I would get 6-8 records when you can look at them and see that all but one clearly do not match...??? Wm | |||
| Advertisements |
| | #2 | ||
| "Wm" <LAshooter@hotmail.com> wrote in message news:lvz%a.2447007$ZC.352429@news.easynews.com... > This is very peculiar -- for some reason, I'm getting 6-8 results from each > of these queries, although only one listing matches. I have a pair of forms > on one page: > > <FORM> > Search for lastname: ____________ [Submit] > </FORM> > <FORM> > Search for email: ________________ [Submit] > </FORM> > > This goes to a searchresults.php page: > > if ($searchname !== "") { > $query="SELECT artistID,firstname,lastname,email,city,state,count ry > from artists WHERE lastname='$searchname'"; > $result=mysql_query($query) or die(mysql_error("Could not execute > query.")); > while($row = mysql_fetch_array($result)) { > $alt_artistID = $row['artistID']; > $alt_firstname = $row['firstname']; > $alt_lastname= $row['lastname']; > $alt_email = $row['email']; > $alt_city = $row['city']; > $alt_state = $row['state']; > $alt_country = $row['country']; > echo "<CENTER><HR>".$alt_artistID."<BR>" > .$alt_firstname." ".$alt_lastname."</A><BR>" > .$alt_email."<BR>" > .$alt_city.", ".$alt_state." ".$alt_country."<BR> > <A HREF=delete.php?aritstID=".$alt_artistID.">DELETE THIS > LISTING?</A><BR></CENTER>"; > } > } > > The second section is identical except for: > if ($searchemail !== "") { > $query="SELECT artistID,firstname,lastname,email,city,state,count ry > from artists WHERE email='$searchemail'"; > etc... > } > > I don't understand why I would get 6-8 records when you can look at them and > see that all but one clearly do not match...??? > > Wm > > > > Try using a "LIKE" with a wildcard instead of "=" to return string matches: e.g.: $query="SELECT artistID,firstname,lastname,email,city,state,count ry from artists WHERE email LIKE '$searchemail'"; Additionally, you can use wildcard matches: $query="SELECT artistID,firstname,lastname,email,city,state,count ry from artists WHERE email LIKE %'$searchemail'%"; The % symbol will return any string which matches the email embedded within the table record. -JD | |||
| | #3 | ||
| On Sat, 16 Aug 2003 23:54:57 GMT, "Wm" <LAshooter@hotmail.com> wrote: >This is very peculiar -- for some reason, I'm getting 6-8 results from each >of these queries, although only one listing matches. I have a pair of forms >on one page: > ><FORM> >Search for lastname: ____________ [Submit] ></FORM> ><FORM> >Search for email: ________________ [Submit] ></FORM> > >This goes to a searchresults.php page: > > if ($searchname !== "") { > $query="SELECT artistID,firstname,lastname,email,city,state,count ry >from artists WHERE lastname='$searchname'"; > $result=mysql_query($query) or die(mysql_error("Could not execute >query.")); [snip] > } > >The second section is identical except for: > if ($searchemail !== "") { > $query="SELECT artistID,firstname,lastname,email,city,state,count ry >from artists WHERE email='$searchemail'"; > etc... > } > >I don't understand why I would get 6-8 records when you can look at them and >see that all but one clearly do not match...??? Can you post a sample of the data that demonstrates this? The SQL queries (as they're being executed, i.e. with the values filled in, not just a variable)? Show the query returning unexpected rows from a mysql command prompt? -- Andy Hassall (andy@andyh.co.uk) icq(5747695) (http://www.andyh.co.uk) Space: disk usage analysis tool (http://www.andyhsoftware.co.uk/space) | |||
| Featured Websites | ||||
|
![]() |
| Tags: getting, many, query, results |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Displaying query results numerous times | szar | PHP | 5 | 07-01-2007 4:15 PM |
| SQL Query - Results from another PHP Page ? | Frank | PHP | 3 | 07-01-2007 3:38 PM |
| Joining many results from one table with one result from another in one query | Piotr Chmielewski | Database | 0 | 06-10-2007 12:20 AM |
| Query MySQL send results in CSV (XLS) | Joe Gazda | Database | 1 | 05-31-2007 8:39 PM |
| Top Search Results | Dicky.Links18@gmail.com | Website Reviews And Website Questions | 0 | 05-28-2007 12:42 AM |
| Featured Websites | ||||
|