par
airbem » 18 juil. 2005, 18:13
comme ceci
$sql_bdd="formulaire"
Il faut savoir que je dois tenir compte de la pagination
Voici mon code
$db_link = mysql_connect("$sql_serveur","$sql_user","$sql_passwd");
$fonction=$_GET['fonction']; // pri a partir d'un menu deroulant
$niveau=$_GET['niveau']; // pri a partir d'un menu deroulant
$mot=$_GET['mot']; // pri à partir champ de type text
$mot=strtolower($mot);
$mots=split(" ",$mot);
$nombre_mots=count($mots);
$z=1;
$texte="Pages contenant <b>"$mots[0]"</b>";
$phrase="'%$mots[0]%'";
while($z<$nombre_mots)
{
$phrase.=" ".$et_ou." mots like '%$mots[$z]%'";
$texte.=" ";
if($et_ou=="and"){$texte.="et";}else{$texte.="ou";}
$texte.=" <b>"$mots[$z]"</b>";
$z++;
}
if($debut==""){$debut=0;}
$debut=$page*$limit;
// NOMBRE TOTAL D'ENREGISTREMENTS REPONDANT A LA REQUETE
$requete=mysql_db_query("$sql_bdd","select count(*) from cv WHERE MATCH ( ref , titre, nom, code, ville, fonction, region1, nom_entr1,prec_ent, nom_entr2 ) AGAINST ('$phrase') AND (fonction LIKE '$fonction' ) AND (niveau LIKE '$niveau')",$db_link);
echo "$requete ";
$nb_total=mysql_result($requete,0,"count(*)");
$requete=mysql_db_query("$sql_bdd","select * from cv WHERE MATCH ( ref , titre , nom ,code, ville, fonction, region1, nom_entr1, prec_ent, nom_entr2) AGAINST ('$phrase') AND (fonction LIKE '$fonction') AND (niveau LIKE '$niveau' ) limit $debut,$limit",$db_link);
$num=mysql_num_rows($requete); // ------- ICI LIGNE 135
// DEFINITION DU MESSAGE A AFFICHER
if ($num==0) {echo "Désolé, aucune page de ce site ne contient
<b>$mot</b>...";}
else if ($mot=="") {echo "Veuillez saisir mot-clés avant de cliquer
sur 'lancer la recherche' !";}
else if (strlen($mot)<2) {echo "Veuillez saisir au moins 2
caractères.";}
// AFFICHAGE DES RESULTATS
else {
echo "<span class=\"style2\"><b>$nb_total</b> réponse</span>";
if ($nb_total>1) {echo "s";}
//echo "<br>$texte";
//$i=0;
while ($tablo = mysql_fetch_object($requete)) {
print "<TR>";
print "<TD><BR></TD>";
print "</TR>";
print "<TR bgcolor=\"#E0ECF8\">";
print "<TD nowrap class=\"style2\" bgcolor=\"#E0ECF8\" ><b>Candidature
à l'offre: </b>$tablo->ref</TD>";
print "<TD>";
print "<TD nowrap class=\"style2\" bgcolor=\"#E0ECF8\"><b>Region
souhaité</b></TD>";
*********************
****************
*****************
****************
}
?>
</table> </td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table>
</body>
</html>
<?
print"<center>";
// AFFICHAGE DU LIEN PRECEDENT SI BESOIN EST
// (LA PREMIERE PAGES EST 0)
if ($page>0)
{
$precedent=$page-1;
print "<a
href=\"$script_name?page=$precedent&mot=$mot&fonction=$fonction&niveau=$niveau\">PRECEDENT</a> \n";
}
// AFFICHAGE DES NUMEROS DE PAGE
$i=0;$j=1;
if($nb_total>$limit)
{
while($i<($nb_total/$limit))
{
if($i!=$page){echo "(<a
href=\"$script_name?page=$i&mot=$mot&fonction=$fonction&niveau=$niveau\">$j</a>) ";}
else {echo "<b>($j)</b> ";}
$i++;$j++;
}
}
// AFFICHAGE DU LIEN SUIVANT SI BESOIN EST
if($debut+$limit<$nb_total)
{
$suivant=$page+1;
echo "<a
href=\"$script_name?page=$suivant&mot=$mot&fonction=$fonction&niveau=$niveau\">SUIVANT</a>";
}
}
print"</center>";
// DECONNEXION DE LA BASE DE DONNEE
mysql_close($db_link);
?>
comme ceci
$sql_bdd="formulaire"
Il faut savoir que je dois tenir compte de la pagination
Voici mon code
[php]
$db_link = mysql_connect("$sql_serveur","$sql_user","$sql_passwd");
$fonction=$_GET['fonction']; // pri a partir d'un menu deroulant
$niveau=$_GET['niveau']; // pri a partir d'un menu deroulant
$mot=$_GET['mot']; // pri à partir champ de type text
$mot=strtolower($mot);
$mots=split(" ",$mot);
$nombre_mots=count($mots);
$z=1;
$texte="Pages contenant <b>"$mots[0]"</b>";
$phrase="'%$mots[0]%'";
while($z<$nombre_mots)
{
$phrase.=" ".$et_ou." mots like '%$mots[$z]%'";
$texte.=" ";
if($et_ou=="and"){$texte.="et";}else{$texte.="ou";}
$texte.=" <b>"$mots[$z]"</b>";
$z++;
}
if($debut==""){$debut=0;}
$debut=$page*$limit;
// NOMBRE TOTAL D'ENREGISTREMENTS REPONDANT A LA REQUETE
$requete=mysql_db_query("$sql_bdd","select count(*) from cv WHERE MATCH ( ref , titre, nom, code, ville, fonction, region1, nom_entr1,prec_ent, nom_entr2 ) AGAINST ('$phrase') AND (fonction LIKE '$fonction' ) AND (niveau LIKE '$niveau')",$db_link);
echo "$requete ";
$nb_total=mysql_result($requete,0,"count(*)");
$requete=mysql_db_query("$sql_bdd","select * from cv WHERE MATCH ( ref , titre , nom ,code, ville, fonction, region1, nom_entr1, prec_ent, nom_entr2) AGAINST ('$phrase') AND (fonction LIKE '$fonction') AND (niveau LIKE '$niveau' ) limit $debut,$limit",$db_link);
$num=mysql_num_rows($requete); // ------- ICI LIGNE 135
// DEFINITION DU MESSAGE A AFFICHER
if ($num==0) {echo "Désolé, aucune page de ce site ne contient
<b>$mot</b>...";}
else if ($mot=="") {echo "Veuillez saisir mot-clés avant de cliquer
sur 'lancer la recherche' !";}
else if (strlen($mot)<2) {echo "Veuillez saisir au moins 2
caractères.";}
// AFFICHAGE DES RESULTATS
else {
echo "<span class=\"style2\"><b>$nb_total</b> réponse</span>";
if ($nb_total>1) {echo "s";}
//echo "<br>$texte";
//$i=0;
while ($tablo = mysql_fetch_object($requete)) {
print "<TR>";
print "<TD><BR></TD>";
print "</TR>";
print "<TR bgcolor=\"#E0ECF8\">";
print "<TD nowrap class=\"style2\" bgcolor=\"#E0ECF8\" ><b>Candidature
à l'offre: </b>$tablo->ref</TD>";
print "<TD>";
print "<TD nowrap class=\"style2\" bgcolor=\"#E0ECF8\"><b>Region
souhaité</b></TD>";
*********************
****************
*****************
****************
}
?>
</table> </td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table>
</body>
</html>
<?
print"<center>";
// AFFICHAGE DU LIEN PRECEDENT SI BESOIN EST
// (LA PREMIERE PAGES EST 0)
if ($page>0)
{
$precedent=$page-1;
print "<a
href=\"$script_name?page=$precedent&mot=$mot&fonction=$fonction&niveau=$niveau\">PRECEDENT</a> \n";
}
// AFFICHAGE DES NUMEROS DE PAGE
$i=0;$j=1;
if($nb_total>$limit)
{
while($i<($nb_total/$limit))
{
if($i!=$page){echo "(<a
href=\"$script_name?page=$i&mot=$mot&fonction=$fonction&niveau=$niveau\">$j</a>) ";}
else {echo "<b>($j)</b> ";}
$i++;$j++;
}
}
// AFFICHAGE DU LIEN SUIVANT SI BESOIN EST
if($debut+$limit<$nb_total)
{
$suivant=$page+1;
echo "<a
href=\"$script_name?page=$suivant&mot=$mot&fonction=$fonction&niveau=$niveau\">SUIVANT</a>";
}
}
print"</center>";
// DECONNEXION DE LA BASE DE DONNEE
mysql_close($db_link);
?>
[/php]