Skip to content
Extraits de code Groupes Projets
Valider a2d5420f rédigé par Imane ALLA's avatar Imane ALLA
Parcourir les fichiers

nombres compacts(classement)

parent a0f857ce
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -21,6 +21,31 @@ include "header.php";
</tr>
</thead>
<tbody>
<?php
function number_format_short( $n, $precision = 1 ) {
if ($n < 900) {
$n_format = number_format($n, $precision);
$suffix = '';
} else if ($n < 900000) {
$n_format = number_format($n / 1000, $precision);
$suffix = 'K';
} else if ($n < 900000000) {
$n_format = number_format($n / 1000000, $precision);
$suffix = 'M';
} else if ($n < 900000000000) {
$n_format = number_format($n / 1000000000, $precision);
$suffix = 'B';
} else {
$n_format = number_format($n / 1000000000000, $precision);
$suffix = 'T';
}
if ( $precision > 0 ) {
$dotzero = '.' . str_repeat( '0', $precision );
$n_format = str_replace( $dotzero, '', $n_format );
}
return $n_format . $suffix;}
?>
<?php
$result = mysqli_query($link, "SELECT nom_artiste, nb_youtube + nb_instagram as nb, tag_instagram FROM influenceurs WHERE nb_youtube != 0 && nb_instagram != 0 ORDER BY nb DESC LIMIT 10");
$compt = 1;
......@@ -28,7 +53,7 @@ include "header.php";
<tr onclick="document.location = 'page_globale.php?user=<?= $row['tag_instagram'] ?>';" class="table-click">
<th scope="row"><?= $compt ?></th>
<td class="text-right"><?php if ($compt == 1) : ?><i class="fas fa-medal"></i><?php endif;?> <?= $row['nom_artiste'] ?></td>
<td class="text-right"><?= $row['nb'] ?></td>
<td class="text-right"><?= number_format_short($row['nb'] , $precision = 1 )?></td>
</tr>
<?php
$compt = $compt + 1;
......@@ -54,7 +79,7 @@ include "header.php";
<tr onclick="document.location = 'instagram-profil.php?user=<?= $row['tag_instagram'] ?>';" class="table-click">
<th scope="row"><?= $compt ?></th>
<td class="text-right"><?php if ($compt == 1) : ?><i class="fas fa-medal"></i><?php endif;?> <?= $row['nom_artiste'] ?></td>
<td class="text-right"><?= $row['nb'] ?></td>
<td class="text-right"><?= number_format_short($row['nb'] , $precision = 1 ) ?></td>
</tr>
<?php
$compt = $compt + 1;
......@@ -79,7 +104,7 @@ include "header.php";
<tr onclick="document.location = 'youtube.php?user=<?= $row['tag_youtube'] ?>';" class="table-click">
<th scope="row"><?= $compt ?></th>
<td class="text-right"><?php if ($compt == 1) : ?><i class="fas fa-medal"></i><?php endif;?> <?= $row['nom_artiste'] ?></td>
<td class="text-right"><?= $row['nb'] ?></td>
<td class="text-right"><?= number_format_short($row['nb'] , $precision = 1 ) ?></td>
</tr>
<?php
$compt = $compt + 1;
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter