Forum de discussion et d'aide au php
Vous n'êtes pas identifié.
|
Regles d'utilisation des forums : pensez à toujours les respecter si vous désirez obtenir des réponses rapides. FAQ : pensez à toujours chercher dedans si la réponse à votre question est dedans. Proposez vos news : si vous avez un evenement à annoncer le chat : venez discuter de php. |
||
BONJOUR
Je souhaite realiser un moteur de recherche sur ma base de connée ; Voici mon scrpt;
<form method="post" action="rechercher.php">
<table width="159" border="0" align="center" cellpadding="0"
cellspacing="0">
<tr>
<td width="67"> <div align="center">
<input name="recherche" type="text" size="20">
</div></td>
<td width="30"></td>
<td width="68"><input type="submit" name="recherche"
value="recherche"> </td>
</tr>
</table>
</form>
Rechercher.php
<html>
<body>
<table width="800" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#FFFFFF">
<TABLE width="100%" BORDER=0 cellpadding=0 cellspacing=0>
<tr>
<TD ALIGN=top><span class="style5">Nom</span></td>
<td></td>
<TD ALIGN=top><span class="style5">Prenom</span></td>
<td></td>
<TD ALIGN=top><span class="style5">code</span></td>
<td></td>
<TD ALIGN=top><span class="style5">ville</span></td>
<td></td>
<TD ALIGN=top><span class="style5">jour de dispo</span></td>
<td></td>
<TD ALIGN=top><span class="style5">Moi de dispo</span></td>
<td></td>
<TD ALIGN=top><span class="style5">Année dispo</span></td>
<td></td>
<TD ALIGN=top><span class="style5">cv</span></td> </TR>
<?
$db = mysql_connect('localhost', 'root', '');
mysql_select_db('formu',$db);
$recherche = $_POST['recherche'];
//Recherche $recherche dans une table
$req ="SELECT nom, prenom,code,ville, dispo_jour,dispo_mois, dispo_annee
FROM form1
WHERE nom LIKE '%$recherche%' OR prenom LIKE '%$recherche%' OR code LIKE '%$recherche%' OR ville LIKE '%$recherche%' OR
fonction LIKE '%$recherche%' OR niveau LIKE '%$recherche%' OR region1 LIKE '%$recherche%' ";
$Erreur = mysql_error();
//on ressort les infos par ordres alphabétiques
$res =mysql_query($req);
if($res === false) die(mysql_error());
while( $tablo = mysql_fetch_object($res))
{
echo "<tr>";
echo "<td nowrap class="style4">".$tablo->nom."</td>";
echo "<td></td>";
echo "<td nowrap class="style4">".$tablo->prenom."</td>";
echo "<td></td>";
echo "<td nowrap class="style4">".$tablo->code."</td>";
echo "<td></td>";
echo "<td nowrap class="style4">".$tablo->ville."</td>";
echo "<td></td>";
echo "<td nowrap class="style4">".$tablo->dispo_jour."</td>";
echo "<td></td>";
echo "<td nowrap class="style4">".$tablo->dispo_mois."</td>";
echo "<td></td>";
echo "<td nowrap class="style4">".$tablo->dispo_annee."</td>";
echo "<td></td>";
echo "<td nowrap class="style6"><a href="fichier/".$tablo->nomDestination."">Telecharger</a></td>";
echo "</tr>";
}
mysql_close();
?>
</table>
</table>
</body>
</html>
Malheuresement comme resulta je n'est qu'un tableau vide alors que m'a base est pleinne.
J'ai fais un echo de ma requet puis je l'ai testé sur phpadmin et elle m' a donnée un resultat .
Je ne vois pas ou est mon erreur.
MERCI POUR VOTRE AIDE
Hors ligne
Bonjour
J'ai fait un test de ma requet sur phpadmin et elle marche .
Mais bon j'ai remodifié un peu mon code .Mais cette fois si j'ai sa comme erreur;
Parse error: parse error in c:program fileseasyphp1-8wwwrechercher.php on line 130.
Recheche.php
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="../stylesheet.css" rel="stylesheet" type="text/css">
</head>
<body>
<table width="800" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#FFFFFF">
<TABLE width="100%" BORDER=0 cellpadding=0 cellspacing=0>
<tr>
<TD ALIGN=top><span class="style5">Nom</span></td>
<td></td>
<TD ALIGN=top><span class="style5">Prenom</span></td>
<td></td>
<TD ALIGN=top><span class="style5">Code postale</span></td>
<td></td>
<TD ALIGN=top><span class="style5">Ville</span></td>
<td></td>
<TD ALIGN=top><span class="style5">Sexe</span></td>
<td></td>
<TD ALIGN=top><span class="style5">Année de naissance</span></td>
<td></td>
<TD ALIGN=top><span class="style5"> Secteur d'activité</span></td>
<td></td>
<TD ALIGN=top><span class="style5"> Année
d'expérience </span></td>
<td></td>
<TD ALIGN=top><span class="style5">Niveau d'études</span></td>
<td></td>
<TD ALIGN=top><span class="style5">Régions souhaitées</span></td>
<td></td>
<TD ALIGN=top><span class="style5">Mobilité géographique
</span></td>
<td></td>
<TD ALIGN=top><span class="style5">Type <br>
</span></td>
<td></td>
<TD ALIGN=top><span class="style5">jour de diponibilité</span></td>
<td></td>
<TD ALIGN=top><span class="style5">Moi de diponibilité</span></td>
<td></td>
<TD ALIGN=top><span class="style5">Année de diponibilité</span></td>
<td></td>
<TD ALIGN=top><span class="style5">cv</span></td> </TR>
<?
$db = mysql_connect('localhost', 'root', '');
mysql_select_db('formu',$db);
if(isset($_GET['recherche']))
{
if($_GET['recherche']=='')
{
echo"<h2>Recherche</h2>";
echo"Veuillez saisir un critère de recherche";
}
elseif(strlen($_GET['recherche'])<3)
{
echo"<h2>Recherche</h2>";
echo"Veuillez saisir un critère de recherche de plus de 3 caractères";
}
else
{
$recherche=$_GET['recherche'];
echo "<title>Recherche de : ".$recherche."</title>
</head><body>
<table align=center width=50%><tr><td><img src=images/panneaux003.gif><td><font size=4 color=white face=Comic Sans MS>Recherche de : ".$rech."</font></table>";
//include("connexion.php");
$rq = "SELECT * FROM form1 WHERE nom LIKE '%$recherche%' OR prenom LIKE '%$recherche%' OR code LIKE '%$recherche%' OR ville LIKE '%$recherche%' OR fonction LIKE '%$recherche%' OR niveau LIKE '%$recherche%' OR region1 LIKE '%$recherche%'";
echo " $rq ";
$res=mysql_query($rq);
$cont=mysql_num_rows($res);
if($cont<=0)
{
echo"<br>Aucun résultat trouvé dans la base de donnée<br><br>";
}
while ($tablo = mysql_fetch_object($res))
{
echo "<tr>";
echo "<td nowrap class="style4" >$tablo->nom</td>";
echo "<td></td>";
echo "<td nowrap class="style4" >$tablo->prenom</td>";
echo "<td></td>";
echo "<td nowrap class="style4" >$tablo->code</td>";
echo "<td></td>";
echo "<td nowrap class="style4">$tablo->ville</td>";
echo "<td></td>";
echo "<td nowrap class="style4">$tablo->sex</td>";
echo "<td></td>";
echo "<td nowrap class="style4" >$tablo->ddn_a</td>";
echo "<td></td>";
echo "<td nowrap class="style4" >$tablo->fonction</td>";
echo "<td></td>";
echo "<td nowrap class="style4" >$tablo->ann_exp</td>";
echo "<td></td>";
echo "<td nowrap class="style4" >$tablo->niveau</td>";
echo "<td></td>";
echo "<td nowrap class="style4" >$tablo->region1</td>";
echo "<td></td>";
echo "<td nowrap class="style4" >$tablo->mobil</td>";
echo "<td></td>";
echo "<td nowrap class="style4" >$tablo->type_mobil</td>";
echo "<td></td>";
echo "<td nowrap class="style4" >$tablo->dispo_jour</td>";
echo "<td></td>";
echo "<td nowrap class="style4">$tablo->dispo_mois</td>";
echo "<td></td>";
echo "<td nowrap class="style4" >$tablo->dispo_annee</td>";
echo "<td></td>";
echo "<td nowrap class="style6" ><a href="cv/$tablo->nomDestination">Telecharger</a></td>";
echo "</tr>";
}
?>
</table>
</table>
</body>
</html> // ici la ligne 130
Envoi.php
<?php
echo'<form method="GET" action="rechercher.php">
<table width="159" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="67"> <div align="center">
<input name="recherche" type="text" size="20">
</div></td>
<td width="30"></td>
<td width="68"><input type="submit" value="cherche"> </td>
</tr>
</table>
</form>';
?>
MERCI POUR VOTRE AIDE
Hors ligne
Dans rechercher.php, il te manque 2 }
Voici ce que tu dois mettre
echo "</tr>"; //Ligne 122
}
}
}
?>
</table>
</table>
</body>
</html> // ici la ligne 130
Hors ligne
au lieu de donner toute ta page, donne uniquement la ligne 130 ...
la premiere chose à faire lorsque tu a une erreur, est de voir la ligne, et de trouver pourquoi il mets cette erreur à cette ligne...
il doit te manquer des }
edit : encore une fois, pas assez rapide lol
Hors ligne
Bonjour
Merci c'est cooll sa marche , Merci beaucoup!!!!!!
J'ai juste un petit souci , j'ai un decallage entre les colonne du tableau et la recherche (ce que l'on a trouvé ) , pas mis au bon endroit, de plus ce que l'on trouve ne prend pas consideration le style associé.
Hors ligne
:oops: ok!!
Je cherche , le comment du pourquoi?
Hors ligne
Re Bonjour
franchement , j'ai retourné mon srcipt dans tous les sens et je suis arrrivé a un resulta qui ma l'air correct ,mais j'ai cette erreur :oops: ;
Parse error: parse error, expecting `','' or `';'' in c:program fileseasyphp1-8wwwrechercher.php on line 89
J'ai bien fermé les guillemé "" partout aprés chaque echo.......
Voici le code remanier;
<?
$db = mysql_connect('localhost', 'root', '');
mysql_select_db('cv_tek',$db);
if(isset($_GET['recherche']))
{
if($_GET['recherche']=='')
{
echo"<h2>Recherche</h2>";
echo"Veuillez saisir un critère de recherche";
}
elseif(strlen($_GET['recherche'])<3)
{
echo"<h2>Recherche</h2>";
echo"Veuillez saisir un critère de recherche de plus de 3 caractères";
}
else
{
$recherche=$_GET['recherche'];
echo "<title>Recherche de : ".$recherche."</title>
<body>
<table align=center width=50%><tr><td>Recherche de : ".$recherche."</font></table>";
//include("connexion.php");
$rq = "SELECT * FROM cv WHERE nom LIKE '%$recherche%' OR prenom LIKE '%$recherche%' OR code LIKE '%$recherche%' OR ville LIKE '%$recherche%' OR fonction LIKE '%$recherche%' OR niveau LIKE '%$recherche%' OR region1 LIKE '%$recherche%'";
//echo " $rq ";
$res=mysql_query($rq);
$cont=mysql_num_rows($res);
if($cont<=0)
{
echo"<br>Aucun résultat trouvé dans la base de donnée<br><br>";
}
else
{
echo "<br><table border='3' cellspacing='0' bordercolor=#D8EDFF width=100%><tr bgcolor='#2080c0'>; // ligne 89
echo "<TD ALIGN=top><span class="style5">Nom</span></td>";
echo "<TD ALIGN=top><span class="style5">Prenom</span></td>";
echo "<TD ALIGN=top><span class="style5">Code postale</span></td>";
echo "<TD ALIGN=top><span class="style5">Ville</span></td>";
echo "<TD ALIGN=top><span class="style5">Sexe</span></td>";
echo "<TD ALIGN=top><span class="style5">Année de naissance</span></td>";
echo "<TD ALIGN=top><span class="style5"> Secteur d'activité</span></td>";
echo " <TD ALIGN=top><span class="style5"> Année d'expérience </span></td>";
echo "<TD ALIGN=top><span class="style5">Niveau d'études</span></td>";
echo " <TD ALIGN=top><span class="style5">Régions souhaitées</span></td>";
echo " <TD ALIGN=top><span class="style5">Mobilité géographique </span></td>";
echo " <TD ALIGN=top><span class="style5">Type <br></span></td>";
echo " <TD ALIGN=top><span class="style5">jour de diponibilité</span></td>";
echo " <TD ALIGN=top><span class="style5">Moi de diponibilité</span></td>";
echo " <TD ALIGN=top><span class="style5">Année de diponibilité</span></td>";
echo " <TD ALIGN=top><span class="style5">cv</span></td>";
echo "</tr>";
while ($tablo = mysql_fetch_object($res))
{
echo "<td nowrap class="style4" >$tablo->nom</td>";
echo "<td nowrap class="style4" >$tablo->prenom</td>";
echo "<td nowrap class="style4" >$tablo->code</td>";
echo "<td nowrap class="style4">$tablo->ville</td>";
echo "<td nowrap class="style4">$tablo->sex</td>";
echo "<td nowrap class="style4" >$tablo->ddn_a</td>";
echo "<td nowrap class="style4" >$tablo->fonction</td>";
echo "<td nowrap class="style4" >$tablo->ann_exp</td>";
echo "<td nowrap class="style4" >$tablo->niveau</td>";
echo "<td nowrap class="style4" >$tablo->region1</td>";
echo "<td nowrap class="style4" >$tablo->mobil</td>";
echo "<td nowrap class="style4" >$tablo->type_mobil</td>";
echo "<td nowrap class="style4" >$tablo->dispo_jour</td>";
echo "<td nowrap class="style4">$tablo->dispo_mois</td>";
echo "<td nowrap class="style4" >$tablo->dispo_annee</td>";
echo "<td nowrap class="style6" ><a href="cv/$tablo->nomDestination">Telecharger</a></td>";
}
echo "</table><br>";
}
}
}
?>
</table>
</table>
</body>
</html>Merci
Hors ligne
LIGNE 89 :
echo "<br><table border='3' cellspacing='0' bordercolor=#D8EDFF width=100%><tr bgcolor='#2080c0'>";
sa ma l'air correct ......enfin je pense . j'ai relancé le programme et j'ai toujours la meme erreur.
Hors ligne
Toujours la meme erreur ,méme aprés modification
J'ai mis sa ;
echo "<br><table border='3' cellspacing='0' bordercolor=#D8EDFF width=100%><tr bgcolor='#2080c0'>";
Jeune jeda , je n'y arrive pas .
Tatatataaaaaata titatataaaaaaaaata ttalalalaaaa
Hors ligne
echo "<TD ALIGN=top><span class="style5">Nom</span></td>";
dans toutes tes lignes d'apres... ton class, tu mets des " alors qu'ils sont deja ouverts pour le echo.
remplace tes lignes :
echo "<TD ALIGN=top><span class="style5">Nom</span></td>";
Hors ligne