www.webdeveloper.com
Results 1 to 5 of 5

Thread: Select lowest bid

  1. #1
    Join Date
    Jun 2011
    Posts
    5

    Question Select lowest bid

    Hello,
    I'd like to select the lowest bid.

    So I selected all bids.
    then i have a foreach, where i get stuck.

    PHP Code:
        foreach($querystrr as $pp2){
            
    $querystr2[] = $database->executeGetOneArray("SELECT * FROM biddings WHERE deviceID = '".$pp2['deviceID']."' ORDER BY bid ASC");
        } 
    I want to print $querystr2's bid value on the screen.



    example, to make it more clear:
    product id | bid
    ------------------
    1 | 5
    2 | 3
    1 | 10
    2 | 6

    So I'll get 10 and 6, and that makes 6 the lowest bid.

  2. #2
    Join Date
    Jun 2011
    Posts
    5
    Changed $querystr2[] to $querystr2, and changed ASC to DESC to get the highest bid.
    Need to print just 1 record per product instead of all multiple times the same record

  3. #3
    Join Date
    Jun 2011
    Posts
    5
    Having single outputs, but ain't able to select the one with the lowest value...
    Anyone a suggestion?

  4. #4
    Join Date
    Jun 2011
    Posts
    5
    Ok, nevermind, got it..

    Just had to set $lowest to 99999999
    then used if($bidding['bid'] < $lowest){
    $lowest = $bidding['bid'];

    }
    in the foreach.

  5. #5
    Join Date
    Dec 2002
    Location
    Pleasanton, CA
    Posts
    2,132
    Why not simply ...
    Code:
    "SELECT * FROM biddings WHERE deviceID='".$pp2['deviceID']."' ORDER BY bid LIMIT 1"
    Will return the lowest value of 'bid' (ORDER BY ... ASC is default)

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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



Recent Articles