SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Jul 2006
    Posts
    31
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Logic help PHP5, OO design and PEAR DB

    Hi,
    my brain is really fried at this point, I wonder if you can assist.

    I'm trying to figure out some logic.

    I have a table with 10 records.. see below
    ID Data
    x1111 5000
    x2222 4500
    x3333 4000
    x4444 3500
    x5555 3000
    x6666 2500
    x7777 2000
    x8888 1500
    x9999 1000
    x11110 500
    x5657 0

    Now I want to pass a value(value-x) to a function getValue. What getValue is supposed to do is obtain the highest value (value-y) from the table which is less than value-x.

    E.g. If value-x = 7000 then the function should return value-y = 5000 since 5000 is the highest value (in the table ) which is less than 7000 (value-x).

    I hope I'm making sense to some one...

    L8r,
    NoTiTo

  2. #2
    eschew sesquipedalians silver trophy sweatje's Avatar
    Join Date
    Jun 2003
    Location
    Iowa, USA
    Posts
    3,749
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    select max(data) from table where data < value-x
    Jason Sweat ZCE - jsweat_php@yahoo.com
    Book: PHP Patterns
    Good Stuff: SimpleTest PHPUnit FireFox ADOdb YUI
    Detestable (adjective): software that isn't testable.


Bookmarks

Posting Permissions

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