Bonjour, je voudrais savoir comment classer les résultats d'une requête mysql du plus grand nombre (le nombre se situe à l'interieur d'un champs nommé nb).
Je m'explique, je fais un moteur de recherche/annuaire, voici les composants de ma table :
titre
des
url
cles
nb
quand on clique sur un site dans mon moteur de recherche, il affiche une page avec un script ajoutant 1 à la table nb. Mais ensuite pendant que le visiteur recherche, je voudrais qu'il affiche les résultats du plus grand nombre de nb au plus petit, pour que les sites soient du plus populaire au moin populaire. Voici ma page de recherche complète, j'éspère que vous comprenderez :
<html>
<?php include('metatags/metatags-general.inc');
$r = explode(' ', $_GET['r']);
$last_word = $r[count($r)-1];
while(list($num, $word) = each($r)){
$req = '`cles` LIKE "%'.$word.'%"';
if($last_word != $word){
$req .= ' OR ';
}
}
include('__conf/mysql_conf.inc');
mysql_connect($serveur, $base, $pass);
mysql_select_db('sonarty');
$requete = mysql_query('SELECT id,titre,des,url,cles FROM sonarty_tout WHERE '.$req.';');
$id=mysql_num_rows($requete);
?>
<head>
<title>Sonarty - Résultat de la recherche</title>
</head>
<body topmargin="0" bottommargin="0">
<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0" WIDTH="762" HEIGHT="100%" ALIGN="CENTER">
<TD WIDTH="11" BACKGROUND="__img/site_01.jpg"> </TD>
<TD WIDTH="740" BGCOLOR="WHITE" VALIGN=TOP">
<table align="left" border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>
<td align="left" width="740" height="73" background="__img/site_12.png">
<?php include('__inc/page-haut.inc'); ?>
</td>
</tr><tr>
<td height="13" background="__img/site_05.png">
</td>
</tr>
<tr>
<td height="8"></td>
</tr>
<tr>
<?php include('__inc/menu-haut.inc'); ?>
</tr>
<tr>
<td width="740" height="1" bgcolor="black"></td>
</tr>
<tr>
<td width="740" align="center" height="65" background="__img/site_13.png"><? include('__pub/script-pub.php'); ?></td>
</tr>
<tr>
<td width="740" height="1" bgcolor="black"></td>
</tr>
<tr>
<td width="740" align="left">
<br>
<table border="0" width="740" cellspacing="0" cellpadding="0">
<td align="left">
<b><font color="gray" face="Verdana" size="2"><? echo $_GET['r']; ?> ></font></b>
</td>
<td align="right">
<b><font color="gray" face="Verdana" size="2">
Il y a <?php echo $id; ?> résultat(s)
</font></b>
</td>
</table><br>
<?php
while ($donnees = mysql_fetch_array($requete) )
{
?>
<table border="0" cellpadding="3" cellspacing="0">
<td>
<a href="sonarty.php?18542=<? echo $donnees['url']; ?>&12378985278-98401=<? echo $donnees['id']; ?>"><font color="blue" size="3"><? echo $donnees['titre']; ?></font></a><br>
<font size="2">
<? echo $donnees['des']; ?>
</font><br>
<font size="2" color="green">
Infos : <? echo $donnees['url']; ?> - ID : <? echo $donnees['id']; ?> - <a style="text-decoration:none" href="#"><font color="green">Haut de page</font></a>
</font><br></td></table>
<?
}
mysql_close();
$r2=$_GET['r'];
mysql_connect("$serveur", "$base", "$pass");
mysql_select_db("sonarty");
mysql_query("INSERT INTO sonarty_clee VALUES('', '$r2')");
mysql_close();
?>
<br>
</td>
</tr>
<tr>
<td height="13" background="__img/site_15.png" width="740"></td>
</tr>
<tr>
<td height="13" background="__img/site_14.png" width="740"></td>
</tr>
</table>
</TD>
<TD WIDTH="11" BACKGROUND="__img/site_02.jpg"> </TD>
</TABLE>
</body>
</html>
Tony1239456