Computer Webmaster Gaming Console Graphics Forum

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.

MK PitStop Main Earn $25 Earn Money Posting Extras Members Blogs Image Hosting User Pages
Go Back   Computer Webmaster Gaming Console Graphics Forum > Webmaster Forum > Website Coding > PHP
Register FAQ/Rules Become A V.I.P. Member Search Today's Posts Mark Forums Read

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.

Google
Closed Thread
 
LinkBack Thread Tools Display Modes
Old 07-01-2007, 5:11 PM   #1
Wm
 
Wm's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default Getting too many results from a query!

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




 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Advertisements
Old 07-01-2007, 5:11 PM   #2
Jamie Davison
 
Jamie Davison's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default Getting too many results from a query!


"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



 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Old 07-01-2007, 5:11 PM   #3
Andy Hassall
 
Andy Hassall's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default Getting too many results from a query!

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)
 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Featured Websites
Free Space
Free Space
Free Space Free Space
Closed Thread
Tags: , , ,




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

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




All times are GMT +1. The time now is 12:14 AM.


Powered by: vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.0.0
Cheap Computers
MK PitStop Copyright 2005 - 2008

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98