Count values of two columns

I’m not sure I can give any more assistance without actually just writing all the code for you. I’ve shown the steps involved. I can’t see why, if you wrote the code you posted, you can’t get this working. You almost had it in post #14, just need to execute the first query and retrieve the results.

Sorry, I’m sure someone else will come and post some helpful advice soon.

// get values for viewing bidder, you might already have these
"SELECT team1_score, team2_score FROM " . $DBPrefix . "bids_perfect_score WHERE bidder = :viewbidder and auction = :auc_id";
// store results in $viewer// get other rows with the same values
"SELECT auction FROM " . $DBPrefix . "bids_perfect_score WHERE team1_score = $viewer[team1_score] and team2_score = $viewer[team2_score] and bidder <> :viewbidder and auction=:auc_id";

$params = array();
$params[] = array(':auc_id', $id, 'int');
$params[] = array(':viewbidder', $user->user_data['id'], 'int');

$db->query($query, $params);
$AUCTION = $db->result();
$template->assign_vars(array(
'BIDDERPERFECTTOTALDOWN' => htmlspecialchars($AUCTION['viewer'])

        ));

ok a bit advice what should be done here plz explain softly so i can work on it from there, thansk

The below query will count the total number of bids per unique combination of scores for a single auction.


SELECT team1_score, team2_score, COUNT(*) bids FROM bids_perfect_score WHERE auct_id = ? GROUP BY team1_score, team2_score;

I gave you the exact query to give the results you asked for. Have you even tried it?

hi it worrks but not the way i want it, this code counts well d total amount of match value but doesnt count the number of bidders who choose the same values as the bidder viewing the page.

it just shows same matched count to all

$query = "SELECT Count( * ) bidderperfecttotal, SUM( bid ) pstotalamount 
FROM " . $DBPrefix . "bids_perfect_score WHERE auction = :auc_id GROUP BY team1_score, team2_score HAVING COUNT( * ) <> 1";

$params = array();
$params[] = array(':auc_id', $id, 'int');
$params[] = array(':bidder', $user->user_data['id'], 'int');

$db->query($query, $params);
$AUCTION = $db->result();
$template->assign_vars(array(
'BIDDERPERFECTTOTALDOWN' => htmlspecialchars($AUCTION['bidderperfecttotal']),
'PS_TOTALAMOUNTDOWN' => htmlspecialchars($AUCTION['pstotalamount'])

        ));    

ok i finally got it to work sorry for late replies been busy offine

$query = "SELECT *, COUNT(*) + 1 AS samebettor FROM " . $DBPrefix . "bids_perfect_score WHERE auction = :auc_id and user != :user and team1_score = :team1_score and team2_score = :team2_score limit 1";

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.