PHP Coding
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsPHP RelatedPHP Coding

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old September 16th, 2002, 05:15 PM
jonpress jonpress is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 9 jonpress User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to jonpress
MySQL multiple queries

I am trying to display the search results for a complex query. I am a newbie and need some help.

Take a look at the following snippet:

$query = mysql_query("SELECT * FROM $usertable WHERE $metode LIKE '%$search%'". "AND $ClassifiedType=$row['Wanted']");

// while($ClassifiedType=$row["Wanted"]) {
while ($row = mysql_fetch_array($query))

Everything before the AND works, but I want to show only these results when column ClassifiedType=Wanted. I tried many different notations, but to no avail. I also tried including it in the while snippet. How does one add these extra parameters?

Reply With Quote
  #2  
Old September 16th, 2002, 05:22 PM
Matt Matt is offline
Moderator
Codewalkers Specialist (4000 - 4499 posts)
 
Join Date: Apr 2007
Location: Florida
Posts: 4,158 Matt User rank is Private First Class (20 - 50 Reputation Level)Matt User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 h 10 m 20 sec
Reputation Power: 6
RE: MySQL multiple queries

It appears that you have the AND pushed directly up against the closing ' mark of the previous where clause. try placing a space before the AND:

$query = mysql_query("SELECT * FROM $usertable WHERE $metode LIKE '%$search%'". " AND $ClassifiedType=$row['Wanted']");

Reply With Quote
  #3  
Old September 16th, 2002, 05:37 PM
jonpress jonpress is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 9 jonpress User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to jonpress
RE: MySQL multiple queries

Thanks for the quick response. I just tried it and the script still does not work.

Reply With Quote
  #4  
Old September 16th, 2002, 05:44 PM
Matt Matt is offline
Moderator
Codewalkers Specialist (4000 - 4499 posts)
 
Join Date: Apr 2007
Location: Florida
Posts: 4,158 Matt User rank is Private First Class (20 - 50 Reputation Level)Matt User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 h 10 m 20 sec
Reputation Power: 6
RE: MySQL multiple queries

You should remove the $ from before the column name such as ClassifiedType..the $ sign denotes a variables in PHP....

Reply With Quote
  #5  
Old September 16th, 2002, 05:54 PM
jonpress jonpress is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 9 jonpress User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to jonpress
RE: MySQL multiple queries

I also added the '(single quote) around Wanted and now it works! Thanks a lot Matt!!

Here is the code snippet that you helped me fix:

$query = mysql_query("SELECT * FROM $usertable WHERE $metode LIKE '%$search%'". " AND ClassifiedType='Wanted'");

Reply With Quote
Reply

Viewing: Codewalkers ForumsPHP RelatedPHP Coding > MySQL multiple queries


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway