/    Sign up×
Community /Pin to ProfileBookmark

counting rows and limit!

i got auction site for highest unique bid is the winner ,and i want to give a limit to users bids ,what i want is that users cannot have 5 bids in a row ,only 4 ,if they bid and the last bid is between the 4 bids they all ready bid ,then the last bid will be deleted, users can have groups of 4 bids in a row not groups of 5 ,my query is in ORDER by bid_price DESC

this is the code i got for the moment but it is limiting the user to have maximum 4 bids from the total of 50:

[code=php]$query = mysql_query(“SELECT * FROM `bidding_details` where bid_id=’$bid_id’ and username=’$username’ order by bid_price desc limit 50″) or die(mysql_error());
$last = ”;
$count = 0;

while($line = mysql_fetch_assoc($query)) {
if($last == $line[‘username’]) $count++;
else {
$last = $line[‘username’];
$count = 1;
}

if($count == 4) {
header(“location:product_detailframe.php?msg=11&&bid_id=$bid_id”);
exit;
}
}[/code]

thanx !!!!

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@MindzaiNov 27.2008 — I'm not sure I understand, the code you posted should limit users to having no more than 4 bids in a row. Is this not what you want? If not could you explain again what it is you would like to happen?
Copy linkTweet thisAlerts:
@canabatzauthorNov 27.2008 — http://www.bonker.co.il/table.jpg

green is good ,the user didnt pass the limit of 4 rows in a run.

red is bad ,user got 5 rows in a run.

the yellow is the last inserted row so it will be deleted!!

thanx for replay ?
×

Success!

Help @canabatz 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,
)...