php MYSQL query multiple options?

Posted on 2011-10-17
Last Modified: 2012-05-12
The below code creates a sql query based on a member_ids value.  I am trying to add an additional criteria so that it only displays records where the PROPERTY_TYPE_CODE is equal to S,D,B or M only but it is now returning all records?  What am I doing wrong?


$member_ids = explode(',',$mymemberid);
foreach ($member_ids as $i=>$val) $member_ids[$i]="'$val'";
$where_clause = "WHERE TLN_REALTOR_ID in (".implode(',',$member_ids).")";

// request query
mysql_select_db($database_Rets, $Rets);

$sql_query = "SELECT * FROM idx_Naples $where_clause AND PROPERTY_TYPE_CODE='S,D,B,M' ORDER BY RAND()";

Open in new window

Question by:pda4me
    LVL 3

    Accepted Solution

    ... AND PROPERTY_TYPE_CODE IN ('S', 'D', 'B', 'M') ORDER BY RAND()";

    Author Closing Comment

    Brilliant, thanks so much!!!

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    If you find yourself in this situation “I have used SELECT DISTINCT but I’m getting duplicates” then I'm sorry to say you are using the wrong SQL technique as it only does one thing which is: produces whole rows that are unique. If the results you a…
    Confronted with some SQL you don't know can be a daunting task. It can be even more daunting if that SQL carries some of the old secret codes used in the Ye Olde query syntax, such as: (+)     as used in Oracle;     *=     =*    as used in Sybase …
    Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
    The viewer will learn how to dynamically set the form action using jQuery.

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now