1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
| <?php
$limit=mysql_real_escape_string($_GET['limit']);
$game=mysql_real_escape_string($_GET['game']);
// Je me connecte à ma base de données
$base = mysql_connect (''.$host.'', ''.$username.'', ''.$pass.'');
mysql_select_db (''.$db.'', $base);
// Définition de la variable qui délimite les items
switch ($limit) {
case "0-25";
$k=0;
$l=25;
break;
case "26-50";
$k=26;
$l=50;
break;
case "51-75";
$k=51;
$l=75;
break;
case "76-100";
$k=76;
$l=100;
break;
case "101-125";
$k=101;
$l=125;
break;
case "126-150";
$k=101;
$l=125;
break;
case "151-175";
$k=101;
$l=125;
break;
case "176-200";
$k=101;
$l=125;
break;
default;
$k=0;
$l=25;
break;
}
$result = mysql_query("SELECT * FROM top Where game='".$game."' ORDER BY point DESC LIMIT $k,$l ")
or die(mysql_error());
// J'initialise une variable à 1
switch ($limit) {
case "0-25";
$i=1;
break;
case "26-50";
$i=26;
break;
case "51-75";
$i=51;
break;
case "76-100";
$i=76;
break;
case "101-125";
$i=101;
break;
case "126-150";
$i=126;
break;
case "151-175";
$i=151;
break;
case "176-200";
$i=176;
break;
default;
$k=0;
$l=25;
break;
}
// Exécution du sql en fonction du paramètre passé dans l'url
$resultat = mysql_query("select * FROM top WHERE game= '$game' ORDER BY point DESC LIMIT $k,$l ");
while($ligne = mysql_fetch_array($resultat)){
// Récupération des informations concernants le serveur
$name=$ligne['name'];
$web=$ligne['web'];
$video=$ligne['video'];
$text=$ligne['text'];
$annonce=$ligne['annonce'];
$point=$ligne['point'];
$nb_clic=$ligne['nb_clic'];
$logo=$ligne['logo'];
$url=$ligne['rewr'];
$id=$ligne['id'];
?>
<div class="ja-box-left" style="width: 100%;">
<div class="module">
<div>
<div>
<div>
<h3><strong><?php echo $i++;?>/</strong> <a style="color:black;" href="out.php?id=<?php echo $id; ?>"><?php echo reduireChaineCar($name, 30);?> </a><font style="float:right; padding-right:5px;">Intérêt : <?php echo $nb_clic; ?></font><font style="float:right; padding-right:5px;"><b>Votes</b> : <font style="color:red;"><?php echo $point; ?></font></font></h3>
<img src="<?php echo $logo; ?>" style="width:410px; height:65px;">
<ul class="latestnews">
<p><?php echo reduireChaineCar(htmlentities(strip_tags($text)), 300);?></p>
</ul> </div>
</div>
</div>
</div>
</div>
<?php
}
/* Fonction qui réduit le nombre de charactères */
function reduireChaineCar($chaine, $nb_car, $delim='...') {
$length = $nb_car;
if($nb_car<strlen($chaine)){
while (($chaine{$length} != " ") && ($length > 0)) {
$length--;
}
if ($length == 0) return substr($chaine, 0, $nb_car) . $delim;
else return substr($chaine, 0, $length) . $delim;
}else return $chaine;
}
/* Fin de ma fonction */
?> |
Partager