begin process at 2012 05 27 20:36:38
  Trouver un code source :
 
dans
 
Accueil > 

Code

 > 

Application

 > TOP LISTE EN PHP + MYSQL

TOP LISTE EN PHP + MYSQL


 Information sur la source

Note :
1 / 10 - par 1 personne
1,00 / 10

  • 1

  • 2

  • 3

  • 4

  • 5

  • 6

  • 7

  • 8

  • 9

  • 10
Catégorie :Application Niveau :Initié Date de création :02/01/2002 Date de mise à jour :02/01/2002 17:36:05 Vu :4 909

Auteur : spidsl

Ecrire un message privé
Site perso
Commentaire sur cette source (6)
Ajouter un commentaire et/ou une note

 Description

#
# Structure de la table `ip_topliste`
#

CREATE TABLE ip_topliste (
  ip varchar(16) NOT NULL default '',
  vote decimal(6,0) NOT NULL default '0',
  jour date NOT NULL default '0000-00-00'
) TYPE=MyISAM;
# -------------------------------------------------- ------

#
# Structure de la table `topliste`
#

CREATE TABLE topliste (
  id int(11) NOT NULL auto_increment,
  titre varchar(150) NOT NULL default '',
  lien varchar(150) NOT NULL default '',
  details varchar(255) NOT NULL default '',
  entrees decimal(6,0) NOT NULL default '0',
  votes decimal(6,0) NOT NULL default '0',
  inscription datetime NOT NULL default '0000-00-00 00:00:00',
  PRIMARY KEY  (id)
) TYPE=MyISAM;

voila la requete sql !
ensuite, changez les variables en haut de page, et pour les votes, c'est votrescript.php?op=voter&sid=id_du_site
Vous pouvez donner le nom que vous voulez a ce script, rien n'y changera !!

Source

  • <?php
  • $host = "localhost";
  • $user= "root";
  • $pass = "pass";
  • $base = "mabase";
  • $c = mysql_connect("$host","$user","$pass");
  • mysql_select_db("$base",$c);
  • function index($debut){
  • print "<CENTER><TITLE>Topliste De mon site perso !</TITLE>Top De mon site perso !<P><FORM method=\"POST\" action=\"$PHP_SELF\">Rechercher: <INPUT type=\"text\" name=\"motcles\" value=\"$motcles\"><INPUT type=\"hidden\" name=\"op\" value=\"rechercher\"> <INPUT type=\"submit\" value=\"Rechercher !\"></FORM><P></CENTER>";
  • if(!isset($debut)){
  • $sql = mysql_query("SELECT * FROM topliste ORDER by votes AND entrees DESC LIMIT 0,20");
  • }
  • elseif($debut){
  • $fin = $debut + 20;
  • $sql = mysql_query("SELECT * FROM topliste ORDER by votes AND entrees DESC LIMIT $debut,$fin");
  • }
  • //$ni = mysql_num_rows(mysql_query("SELECT * FROM topliste"));
  • print "<CENTER><TABLE align=center border=\"1\" cellspacing=0 cellpadding=0 width=\"90%\">";
  • print "<TR><TD align=center width=\"10%\">Place</TD><TD align=center width=\"70%\">Détails</TD><TD align=center width=\"10%\">Entrées</TD><TD align=center width=\"10%\">Votes</TD></TR>";
  • if($debut)
  • $j = $debut;
  • while(list($id,$titre,$lien,$details,$entrees,$votes,$datei,$login,$pass)=mysql_fetch_row($sql)){
  • $j++;
  • print "<TR><TD align=center width=\"10%\">$j.</TD><TD align=center width=\"70%\"><CENTER><A HREF=\"$PHP_SELF?op=visiter&sid=$id\" target=\"_blank\">$titre</A><BR>$details</CENTER></TD><TD align=center width=\"10%\">$entrees</TD><TD align=center width=\"10%\">$votes<BR><a HREF=\"$PHP_SELF?op=voter&sid=$id\">Voter</A></TD></TR>";
  • }
  • print "</TABLE></CENTER>";
  • $nb = mysql_num_rows(mysql_query("SELECT * FROM topliste"));
  • if($nb > 20){
  • $nb = $nb / 20;
  • $nb = ceil($nb);
  • $nb = $nb + 1;
  • echo "<CENTER>";
  • for($i=1; $i < $nb; $i++){
  • $d = $i;
  • if($i == 1){
  • $d = $i - 1;
  • }
  • $debut = $d.'0';
  • print "<A HREF=\"$PHP_SELF?debut=$debut\">$i</A>&nbsp;";
  • }
  • echo "</CENTER>";
  • }
  • }
  • function rechercher($motcles,$debut){
  • if(!isset($debut)){
  • print "<CENTER><TITLE>Top Liste De mon site perso !</TITLE>Top Liste De mon site perso ! <P><FORM method=\"POST\" action=\"$PHP_SELF\">Rechercher: <INPUT type=\"text\" name=\"motcles\" value=\"$motcles\"><INPUT type=\"hidden\" name=\"op\" value=\"rechercher\"> <INPUT type=\"submit\" value=\"Rechercher !\"></FORM><P></CENTER>";
  • $sql = mysql_query("SELECT * FROM topliste WHERE details LIKE '%$motcles%' OR titre LIKE '%$motcles%' ORDER by votes AND entrees DESC LIMIT 0,20");
  • }
  • elseif($debut){
  • $fin = $debut + 20;
  • $sql = mysql_query("SELECT * FROM topliste WHERE details LIKE '%$motcles%' OR titre LIKE '%$motcles%' ORDER by votes AND entrees DESC LIMIT $debut,$fin");
  • }
  • $nnnp = mysql_num_rows($sql);
  • print "<CENTER>Il y a $nnnp résultat(s) correspondant à la recherche <I>$motcles</I>.<P></CENTER>";
  • print "<CENTER><TABLE align=center border=\"1\" cellspacing=0 cellpadding=0 width=\"90%\">";
  • print "<TR><TD align=center width=\"10%\">Place</TD><TD align=center width=\"70%\">Détails</TD><TD align=center width=\"10%\">Entrées</TD><TD align=center width=\"10%\">Votes</TD></TR>";
  • if($debut)
  • $j = $debut;
  • while(list($id,$titre,$lien,$details,$entrees,$votes,$datei,$login,$pass)=mysql_fetch_row($sql)){
  • $j++;
  • print "<TR><TD align=center width=\"10%\">$j.</TD><TD align=center width=\"70%\"><CENTER><A HREF=\"$PHP_SELF?op=visiter&sid=$id\" target=\"_blank\">$titre</A><BR>$details</CENTER></TD><TD align=center width=\"10%\">$entrees</TD><TD align=center width=\"10%\">$votes<BR><A HREF=\"$PHP_SELF?op=voter&sid=$id\">Voter</A></TD></TR>";
  • }
  • print "</TABLE></CENTER>";
  • $nb = mysql_num_rows(mysql_query("SELECT * FROM topliste WHERE titre LIKE '%$motcles%' OR details LIKE '%$motcles%'"));
  • if($nb > 20){
  • $nb = $nb / 20;
  • $nb = ceil($nb);
  • $nb = $nb + 1;
  • echo "<CENTER>";
  • for($i=1; $i < $nb; $i++){
  • $d = $i;
  • if($i == 1){
  • $d = $i - 1;
  • }
  • $debut = $d.'0';
  • print "<A HREF=\"$PHP_SELF?debut=$debut\">$i</A>&nbsp;";
  • }
  • echo "</CENTER>";
  • }
  • }
  • function visiter($sid){
  • $sql = mysql_query("SELECT id,lien,entrees FROM topliste WHERE id='$sid'");
  • list($id,$lien,$entrees) = mysql_fetch_row($sql);
  • $ne = $entrees + 1;
  • @mysql_query("UPDATE topliste SET entrees='$ne' WHERE id='$sid'") or print "IMPOSSIBLE DE COMPTABILISER VOTRE VISITE !";
  • header("Location:$lien");
  • }
  • function voter($sid){
  • $sql = mysql_query("SELECT id,lien,votes FROM topliste WHERE id='$sid'");
  • list($id,$lien,$votes) = mysql_fetch_row($sql);
  • $ne = $votes + 1;
  • $auj = date("Y:m:d");
  • $nbip = mysql_num_rows(mysql_query("SELECT * FROM ip_topliste WHERE ip='$REMOTE_ADDR' AND vote='$sid' AND jour='$auj'"));
  • $nbip2 = mysql_num_rows(mysql_query("SELECT * FROM ip_topliste"));
  • if($nbip == "0"){
  • @mysql_query("UPDATE topliste SET votes='$ne' WHERE id='$sid'") or print "IMPOSSIBLE DE COMPTABILISER VOTRE VISITE !";
  • @mysql_query("INSERT INTO ip_topliste VALUES('$REMOTE_ADDR','$sid','$auj')") or print "IMPOSSIBLE d'AJOUTER IP !";
  • }
  • @mysql_query("DELETE FROM ip_visiteurs WHERE date!='$auj'");
  • index("00");
  • }
  • switch($op){
  • case "voter":
  • voter($sid);
  • break;
  • case "rechercher":
  • rechercher($motcles,$debut);
  • break;
  • case "visiter":
  • visiter($sid);
  • break;
  • default:
  • index($debut);
  • break;
  • }
  • ?>
<?php
$host = "localhost";
$user= "root";
$pass = "pass";
$base = "mabase";
$c = mysql_connect("$host","$user","$pass");
mysql_select_db("$base",$c);
function index($debut){
print "<CENTER><TITLE>Topliste De mon site perso !</TITLE>Top De mon site perso !<P><FORM method=\"POST\" action=\"$PHP_SELF\">Rechercher: <INPUT type=\"text\" name=\"motcles\" value=\"$motcles\"><INPUT type=\"hidden\" name=\"op\" value=\"rechercher\"> <INPUT type=\"submit\" value=\"Rechercher !\"></FORM><P></CENTER>";
if(!isset($debut)){
$sql = mysql_query("SELECT * FROM topliste ORDER by votes AND entrees DESC LIMIT 0,20");
}
elseif($debut){
$fin = $debut + 20;
$sql = mysql_query("SELECT * FROM topliste ORDER by votes AND entrees DESC LIMIT $debut,$fin");
}
//$ni = mysql_num_rows(mysql_query("SELECT * FROM topliste"));
print "<CENTER><TABLE align=center border=\"1\" cellspacing=0 cellpadding=0 width=\"90%\">";
print "<TR><TD align=center width=\"10%\">Place</TD><TD align=center width=\"70%\">Détails</TD><TD align=center width=\"10%\">Entrées</TD><TD align=center width=\"10%\">Votes</TD></TR>";
if($debut)
$j = $debut;
while(list($id,$titre,$lien,$details,$entrees,$votes,$datei,$login,$pass)=mysql_fetch_row($sql)){
$j++;
print "<TR><TD align=center width=\"10%\">$j.</TD><TD align=center width=\"70%\"><CENTER><A HREF=\"$PHP_SELF?op=visiter&sid=$id\" target=\"_blank\">$titre</A><BR>$details</CENTER></TD><TD align=center width=\"10%\">$entrees</TD><TD align=center width=\"10%\">$votes<BR><a HREF=\"$PHP_SELF?op=voter&sid=$id\">Voter</A></TD></TR>";
}
print "</TABLE></CENTER>";
$nb = mysql_num_rows(mysql_query("SELECT * FROM topliste"));
if($nb > 20){
$nb = $nb / 20;
$nb = ceil($nb);
$nb = $nb + 1;
echo "<CENTER>";
for($i=1; $i < $nb; $i++){
$d = $i;
if($i == 1){
$d = $i - 1;
}
$debut = $d.'0';
print "<A HREF=\"$PHP_SELF?debut=$debut\">$i</A>&nbsp;";
}
echo "</CENTER>";
}
}

function rechercher($motcles,$debut){
if(!isset($debut)){
print "<CENTER><TITLE>Top Liste De mon site perso !</TITLE>Top Liste De mon site perso ! <P><FORM method=\"POST\" action=\"$PHP_SELF\">Rechercher: <INPUT type=\"text\" name=\"motcles\" value=\"$motcles\"><INPUT type=\"hidden\" name=\"op\" value=\"rechercher\"> <INPUT type=\"submit\" value=\"Rechercher !\"></FORM><P></CENTER>";
$sql = mysql_query("SELECT * FROM topliste WHERE details LIKE '%$motcles%' OR titre LIKE '%$motcles%' ORDER by votes AND entrees DESC LIMIT 0,20");
}
elseif($debut){
$fin = $debut + 20;
$sql = mysql_query("SELECT * FROM topliste WHERE details LIKE '%$motcles%' OR titre LIKE '%$motcles%' ORDER by votes AND entrees DESC LIMIT $debut,$fin");
}
$nnnp = mysql_num_rows($sql);
print "<CENTER>Il y a $nnnp résultat(s) correspondant à la recherche <I>$motcles</I>.<P></CENTER>";
print "<CENTER><TABLE align=center border=\"1\" cellspacing=0 cellpadding=0 width=\"90%\">";
print "<TR><TD align=center width=\"10%\">Place</TD><TD align=center width=\"70%\">Détails</TD><TD align=center width=\"10%\">Entrées</TD><TD align=center width=\"10%\">Votes</TD></TR>";
if($debut)
$j = $debut;
while(list($id,$titre,$lien,$details,$entrees,$votes,$datei,$login,$pass)=mysql_fetch_row($sql)){
$j++;
print "<TR><TD align=center width=\"10%\">$j.</TD><TD align=center width=\"70%\"><CENTER><A HREF=\"$PHP_SELF?op=visiter&sid=$id\" target=\"_blank\">$titre</A><BR>$details</CENTER></TD><TD align=center width=\"10%\">$entrees</TD><TD align=center width=\"10%\">$votes<BR><A HREF=\"$PHP_SELF?op=voter&sid=$id\">Voter</A></TD></TR>";
}
print "</TABLE></CENTER>";


$nb = mysql_num_rows(mysql_query("SELECT * FROM topliste WHERE titre LIKE '%$motcles%' OR details LIKE '%$motcles%'"));
if($nb > 20){
$nb = $nb / 20;
$nb = ceil($nb);
$nb = $nb + 1;
echo "<CENTER>";
for($i=1; $i < $nb; $i++){
$d = $i;
if($i == 1){
$d = $i - 1;
}
$debut = $d.'0';
print "<A HREF=\"$PHP_SELF?debut=$debut\">$i</A>&nbsp;";
}
echo "</CENTER>";
}
}

function visiter($sid){
$sql = mysql_query("SELECT id,lien,entrees FROM topliste WHERE id='$sid'");
list($id,$lien,$entrees) = mysql_fetch_row($sql);
$ne = $entrees + 1;
@mysql_query("UPDATE topliste SET entrees='$ne' WHERE id='$sid'") or print "IMPOSSIBLE DE COMPTABILISER VOTRE VISITE !";
header("Location:$lien");
}

function voter($sid){
$sql = mysql_query("SELECT id,lien,votes FROM topliste WHERE id='$sid'");
list($id,$lien,$votes) = mysql_fetch_row($sql);
$ne = $votes + 1;
$auj = date("Y:m:d");
$nbip = mysql_num_rows(mysql_query("SELECT * FROM ip_topliste WHERE ip='$REMOTE_ADDR' AND vote='$sid' AND jour='$auj'"));
$nbip2 = mysql_num_rows(mysql_query("SELECT * FROM ip_topliste"));
if($nbip == "0"){
@mysql_query("UPDATE topliste SET votes='$ne' WHERE id='$sid'") or print "IMPOSSIBLE DE COMPTABILISER VOTRE VISITE !";
@mysql_query("INSERT INTO ip_topliste VALUES('$REMOTE_ADDR','$sid','$auj')") or print "IMPOSSIBLE d'AJOUTER IP !";
}
@mysql_query("DELETE FROM ip_visiteurs WHERE date!='$auj'");
index("00");
}

switch($op){

case "voter":
voter($sid);
break;

case "rechercher":
rechercher($motcles,$debut);
break;

case "visiter":
visiter($sid);
break;

default:
index($debut);
break;
}
?> 

 Conclusion

Aucun bug connu :) !
MErci a moi, webmaster de http://www.spidsl.com !


 Sources de la même categorie

Source avec une capture PHPREPOGENERATOR + REPO (WIN) par alvinp
Source avec Zip IPHONE - ICÔNE D'APPEL TÉLÉPHONIQUE SUR L'ÉCRAN D'ACCUEIL par Rainbow
Source avec Zip Source avec une capture [APP WEB]SERVEUREXPLOREUR par thematrix01
Source avec Zip Source avec une capture MY.BOOKMARKS par inwebo
Source avec Zip M.V.C M.E.D par faceme

Commentaires et avis

Commentaire de jeunegob le 02/03/2005 18:34:34

tu pourai pas faire un zip sa coute rien !

Commentaire de BOB34MAL66 le 07/03/2005 07:34:45

et un script pour rentrer les sites a voter

Commentaire de bazouil le 30/06/2006 11:32:35

Ton code est vraiment catastrophique, pour le comprendre, il faut mettre du temps. Il faut vraiment que tu apprennes a coder proprement. Mais bon, c'est vrai que ca marche bien.

Commentaire de daweb le 11/11/2006 23:11:50

Comment je vais me faire repérer dans ce script j'ai dèja enregistré le nom de domaine du top liste

Commentaire de KarSess le 05/02/2008 17:34:39

complètement inutile a banir

Commentaire de fabrice88 le 04/11/2008 13:11:26

KarSess  des commentaires comme le tiens ne servent a rien. Tu ferais bien de ne rien dire si c'est pour critiqué inutilement.
Si tu n'y vois pas d'intérêt passe ton chemin car d'autres trouverons surement l'utilité du script de spidsl.
Merci Spidsl pour ta participation, je ne suis que debutant en php et ton script va surement me servir.

 Ajouter un commentaire




Nos sponsors


Sondage...

Comparez les prix

CalendriCode

Mai 2012
LMMJVSD
 123456
78910111213
14151617181920
21222324252627
28293031   

Consulter la suite du CalendriCode

A découvrir



 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 0,546 sec (3)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales