Skip to content
Extraits de code Groupes Projets
Sélectionner une révision Git
  • 9ded4c5d440aeda41a2406e8c914365bec86cf6b
  • master par défaut protégée
2 résultats

favoris.php

Blame
  • favoris.php 6,38 Kio
    <?php
    include "./config/database.php";
    include "header.php";
    if (isset($_SESSION["authent"]) && $_SESSION['authent'] == 0){
    	echo "
    	<meta http-equiv=\"refresh\" content=\"0; url=index.php\">";
    	exit();
    }
    ?>
    
        <div class="text-center fadeInUp animated pt-4">
            <h1>Favoris</h1>
        </div>
    </header>
    
    <section class="one">
        <div class="container">
            <h2>Top 10 Favoris</h2>
            <div class="divider"></div>
            <table class="table">
                <thead class="thead-dark">
                    <tr>
                    <th scope="col">#</th>
                    <th scope="col" class="text-right">Nom</th>
                    <th scope="col" class="text-right">Nombre de Followers</th>
                    </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 NATURAL JOIN favoris WHERE nb_youtube != 0 && nb_instagram != 0 && id_user = ".$_SESSION["id"]." ORDER BY nb DESC LIMIT 10");
                    $compt = 1;
                    $compt2=1;
                    while($row = mysqli_fetch_assoc($result)) : $compt2=2;?>
                        <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"><?=  number_format_short($row['nb'] , $precision = 1 ) ?></td>
                        </tr>
                    <?php
                        $compt=$compt+1;
                    endwhile; ?>
                </tbody>
                
            </table>
            <?php if ($compt2==1) echo "Pas de favoris <br/><br/><br/>"; ?>
        </div>