1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| $resultat = array();
$criteres = array( '...','...', '....' );
$stmt = $pdo->prepare( 'SELECT id, champ FROM table WHERE champ LIKE ?' );
Foreach( $criteres as $critere ){
$res = $stmt -> execute ( array( $critere ) );//node fetch associatif...
foreach ( $res as $couple ){
if ( isset( $resultat[$couple['id']] ){
$resultat[$couple['id']]['note']++;
}
else {
$resultat[$couple['id']]=array( 'note' => 0, 'champ' => $couple['champ'], 'id' => $couple['id'] );
}
}//$res inter
unset($res);
}//critere
function customSort($a,$b){
return $a['note'] - $b['note']; //verifier le sens
}
ursort( $resultat, 'customSort' ); |