/    Sign up×
Community /Pin to ProfileBookmark

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.

[code=php]
foreach($querystrr as $pp2){
$querystr2[] = $database->executeGetOneArray(“SELECT * FROM biddings WHERE deviceID = ‘”.$pp2[‘deviceID’].”‘ ORDER BY bid ASC”);
}
[/code]

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.

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@AdnarimauthorJun 08.2011 — 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
Copy linkTweet thisAlerts:
@AdnarimauthorJun 08.2011 — Having single outputs, but ain't able to select the one with the lowest value...

Anyone a suggestion?
Copy linkTweet thisAlerts:
@AdnarimauthorJun 08.2011 — Ok, nevermind, got it..

Just had to set $lowest to 99999999

then used if($bidding['bid'] < $lowest){

$lowest = $bidding['bid'];

}
in the foreach.
Copy linkTweet thisAlerts:
@NedalsJun 08.2011 — Why not simply ...
<i>
</i>"SELECT * FROM biddings WHERE deviceID='".$pp2['deviceID']."' ORDER BY bid LIMIT 1"

Will return the lowest value of 'bid' (ORDER BY ... ASC is default)
×

Success!

Help @Adnarim spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...