Reply
Query help
Old 01-30-2005, 02:15 AM Query help
Average Talker

Posts: 29
Can someone help me out with a mysql query?

I am trying to get a list of rows that match one of two category columns that are in a city. Im sure IN isn't valid syntax for queries so can someone help me out?

PHP Code:
mysql_query("SELECT * FROM restaurants WHERE cat=$cat AND subcat=$cat IN city=$city",$db
Thanks if anyone can help
colincameron is offline
Reply With Quote
View Public Profile Visit colincameron's homepage!
 
When You Register, These Ads Go Away!
Old 01-30-2005, 03:08 AM
Logical Program's Avatar
Super Talker

Posts: 130
Location: Atlanta, Georgia
The , $db isn't necessary, and the IN is incorrect; doesn't exist. You must also quote the comparison. Try this:

PHP Code:
$query mysql_query("SELECT * FROM restaurants WHERE cat='$cat' AND subcat='$cat'");
while (
$output mysql_fetch_array($query)){
    echo 
$output[arrayVALUE].'<br>';

__________________
Logical Programming - For all of your website programming and design needs, make the logical choice. Logical Assistance For Real-World Clients.

Last edited by Logical Program : 01-30-2005 at 03:23 AM.
Logical Program is offline
Reply With Quote
View Public Profile Visit Logical Program's homepage!
 
Old 01-30-2005, 03:11 AM
Average Talker

Posts: 29
Thanks Logical Program but I just posted a portion of the code I have all that. With that out of the way can anyone help me with the problem.
colincameron is offline
Reply With Quote
View Public Profile Visit colincameron's homepage!
 
Old 01-30-2005, 03:15 AM
Logical Program's Avatar
Super Talker

Posts: 130
Location: Atlanta, Georgia
The corrected version of your portion was in the $query variable.
__________________
Logical Programming - For all of your website programming and design needs, make the logical choice. Logical Assistance For Real-World Clients.
Logical Program is offline
Reply With Quote
View Public Profile Visit Logical Program's homepage!
 
Old 01-30-2005, 03:22 AM
Average Talker

Posts: 29
Maybe im confused.. My query works fine this is the section that im trying to change

PHP Code:
$result mysql_query("SELECT * FROM restaurants WHERE cat=$catid",$db);
    
    if (
$r_row mysql_fetch_array($result)) { 
So right now this work fine, it shows every row that matches the cat column. but im trying to select only the rows that are in the city column which $cat matchs cat and subcat columns.

Is this possible?
colincameron is offline
Reply With Quote
View Public Profile Visit colincameron's homepage!
 
Old 01-30-2005, 03:28 AM
Logical Program's Avatar
Super Talker

Posts: 130
Location: Atlanta, Georgia
I'm lost... You can't have rows in a column. Is city a field in the restaurants table? IF so, try:

PHP Code:
mysql_query("SELECT * FROM restaurants WHERE city='$x' AND cat='$cat' AND subcat='$cat'"); 
__________________
Logical Programming - For all of your website programming and design needs, make the logical choice. Logical Assistance For Real-World Clients.
Logical Program is offline
Reply With Quote
View Public Profile Visit Logical Program's homepage!
 
Old 01-30-2005, 03:30 AM
Average Talker

Posts: 29
Yes! thats what im looking for.. Sorry i was a bit unclear before, i dont know what im talking about. =)
colincameron is offline
Reply With Quote
View Public Profile Visit colincameron's homepage!
 
Old 01-30-2005, 03:33 AM
Logical Program's Avatar
Super Talker

Posts: 130
Location: Atlanta, Georgia
Glad I could help; You were losing me there for a second.
__________________
Logical Programming - For all of your website programming and design needs, make the logical choice. Logical Assistance For Real-World Clients.
Logical Program is offline
Reply With Quote
View Public Profile Visit Logical Program's homepage!
 
Reply     « Reply to Query help
 

Thread Tools

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 Off
Pingbacks are Off
Refbacks are Off


Webmaster Resources Marketplace:
Software Development Company | Webhosting.UK.com | Text Link Brokers 


   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.15164 seconds with 12 queries