Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Dec 2003
    Location
    texas
    Posts
    96
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Simple PHP question

    Can someone tell me what is wrong with this php statement?
    Code:
    $query3 = "SELECT `Premium` AS 'premium' FROM `Premiums` where 'ID' > 3 && > 5"
    This is the beginning of the code. I am making a listbox where someone clicks something in it...it displays the corresponding information in another area.
    thanks
    bri

  • #2
    Senior Coder
    Join Date
    Mar 2003
    Location
    Atlanta
    Posts
    1,037
    Thanks
    14
    Thanked 30 Times in 28 Posts
    Quote Originally Posted by briintex1 View Post
    Code:
     where 'ID' > 3 && > 5"
    Whats this mean?
    Most of my questions/posts are fairly straightforward and simple. I post long verbose messages in an attempt to be thorough.

  • #3
    New Coder
    Join Date
    Dec 2003
    Location
    texas
    Posts
    96
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Basically what I am trying to do is display everything where ID is between two numbers...if I put 5 and 7 in the numbers it should display only 6.

    If I have this
    Code:
    		$query3 = "SELECT `Premium` AS 'premium' FROM `Premiums` where 'ID' > 5 && 'ID' > 7";
    my list box shows everything and and the text box shows undefined.

    If I have
    Code:
    $query3 = "SELECT `Premium` AS 'premium' FROM `Premiums`";
    Then it displays everything just fine.

    I am lost on the first snippet of code.
    thanks
    bri

  • #4
    Senior Coder
    Join Date
    Mar 2003
    Location
    Atlanta
    Posts
    1,037
    Thanks
    14
    Thanked 30 Times in 28 Posts
    Well you do realize that you have single quotes on 'ID' and not backticks `ID`. Additionally, you can use the BETWEEN ...AND operators.

    Code:
    SELECT column_name FROM table_name
    WHERE column_name
    BETWEEN value1 AND value2
    Most of my questions/posts are fairly straightforward and simple. I post long verbose messages in an attempt to be thorough.


  •  

    Posting Permissions

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