Results 1 to 2 of 2
  1. #1
    ABW Ambassador Doug247's Avatar
    Join Date
    January 18th, 2005
    Location
    DE USA
    Posts
    931
    I am trying to get a MySQL query to work but I'm just not getting it.


    Here is what I have:

    select * from $tablename Where (SUBCAT1 = \"$_GET[SC1]\" or SUBCAT2 = \"$_GET[SC2]\") and CATAGORY = \"$_GET[CAT]\"

    I am trying to have it select records that match a "Catagory" and match either "SUBCAT1" or "SUBCAT2"

    Make sense. Please Help.

    Thanks,
    DOug
    Thanks,
    Doug

  2. #2
    Member
    Join Date
    January 18th, 2005
    Location
    Montreal
    Posts
    68
    I'd use:

    $sql = "SELECT * FROM $tablename WHERE CATAGORY='" . $_GET['CAT'] . "' AND (SUBCAT1='" . $_GET['SC1'] . "' OR SUBCAT2='" . $_GET['SC2'] . "');";

    This assumes that "Catagory", "SUBCAT1" and "SUBCAT2" are all strings and not numbers (if they are numbers then remove the single quotes before the double quotes).
    <A HREF="http://www.affmarketing.org/">The Affiliate Marketing Blog</A>: Check out my latest entry on "Affiliate Marketing on a Dime"

  3. Newsletter Signup

+ Reply to Thread

Similar Threads

  1. Using an array from a mysql field in a select statement
    By knight01 in forum Programming / Datafeeds / Tools
    Replies: 9
    Last Post: May 9th, 2010, 10:16 PM
  2. show select products on index page with IF statement
    By sweetiowa in forum WebMerge (Fourthworld.com)
    Replies: 3
    Last Post: October 13th, 2007, 08:30 PM
  3. [php] Self-Updating Select Menu
    By mobilebadboy in forum Programming / Datafeeds / Tools
    Replies: 3
    Last Post: April 6th, 2006, 10:05 AM
  4. LIKE '%$categoryid%' works = doesn't in select statement
    By suzie250 in forum Programming / Datafeeds / Tools
    Replies: 5
    Last Post: January 17th, 2006, 09:37 PM
  5. Is there a Select Case in PHP?
    By Doug247 in forum Programming / Datafeeds / Tools
    Replies: 1
    Last Post: May 5th, 2004, 01:09 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •