Database Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesDatabase Help

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 November 7th, 2002, 03:57 AM
Scurvy Scurvy is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Ormond Beach, FL USA
Posts: 26 Scurvy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Help with a AND/OR b AND/OR c sql query

I inadvertantly posted this in the php forum so it's not really a repost

I need help with the following sql query:

php Code:
Original - php Code
  1. $result = mysql_query("SELECT * FROM images WHERE color = $'color' AND year = '$year' AND model = '$model' order by year asc",$db);

That's the basics. What I really want to do is have a search on 3 keywords that will display an image based on those selections.
If the user picks blue 1998 mustang I want to search:
Each picture has 3 keywords: color, year and model.
color = blue AND year = 1998 AND model = mustang
If the user picks red 2002 viper then :
color = red AND year = 2002 AND model = viper.

It works fine if I only use:
php Code:
Original - php Code
  1.  
  2. $result = mysql_query("SELECT * FROM images WHERE model = '$model'order by year asc",$db);

or year = $year, etc. If I use the AND it doesn't show anything.

Also, if the user only picks two (like color and model) I want to include any year matching the color and model they've
chosen.

Any ideas would be greatly appreciated.

Jeff

Reply With Quote
  #2  
Old November 7th, 2002, 06:47 PM
bob0099 bob0099 is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: manchester,n.h.,usa
Posts: 172 bob0099 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
RE: Help with a AND/OR b AND/OR c sql query

It looks like your syntax is off on this:
WHERE color = $'color'

Try
WHERE color = '$color'

good luck

Reply With Quote
  #3  
Old November 7th, 2002, 06:48 PM
bob0099 bob0099 is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: manchester,n.h.,usa
Posts: 172 bob0099 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
RE: Help with a AND/OR b AND/OR c sql query

It looks like your syntax is off on this:
WHERE color = $'color'

Try
WHERE color = '$color'

good luck

Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesDatabase Help > Help with a AND/OR b AND/OR c sql query


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 6 hosted by Hostway
Stay green...Green IT