Moteur de recherche sur plusieurs tables
Posté : 24 avr. 2007, 15:29
Bonjour,
J'aimerais avoir votre aide pour coder un moteur de recherche interne à mon site de vente en ligne.
J'ai trouvé plusieurs tutoriel sur google mais qui recherche un mot dans une seule table.
Se que j'aimerais c'est effectuer une recherche selon la categorie de produit et selon l'attribut de produits choisie.
Voici les table a rechercher:
Le formulaire du moteur de recherche est composé de <select>
Voici mon formulaire:
Merci!
J'aimerais avoir votre aide pour coder un moteur de recherche interne à mon site de vente en ligne.
J'ai trouvé plusieurs tutoriel sur google mais qui recherche un mot dans une seule table.
Se que j'aimerais c'est effectuer une recherche selon la categorie de produit et selon l'attribut de produits choisie.
Voici les table a rechercher:
- produits
produits_attributs
produits_attributs_details
Le formulaire du moteur de recherche est composé de <select>
Voici mon formulaire:
include("config.php");
echo "<table width=\"100%\" align=\"center\" CELLPADDING=\"1\" CELLSPACING=\"1\" class=\"border\">\n";
echo "<TR>\n";
echo "<TD class=\"border3\" align=\"center\"><b>".panier_76."</b></td>\n";
echo "</tr>\n";
echo "<TR>\n";
echo "<TD>\n";
echo "<form action=\"recherche.php\" method=\"post\">\n";
mysql_connect($host,$login,$password) or die("Impossible de connecter la bd");
$base=mysql_select_db($db) or die("erreur de DB");
$sql=mysql_query("select * from produits_categories order by categorie_id ASC") or die("Impossible d'ouvrir la table");
echo "<b>".panier_78."</b>\n";
echo "<select name='categorie_id'>\n";
echo "<option value=\"0\">".panier_74."</option>\n";
while ($categorie=mysql_fetch_array($sql))
{
echo "<option value=\"".$categorie["categorie_id"]."\">".stripslashes($categorie["nom_cat_".$_SESSION["lang"].""])."</option>\n";
}
echo "</select>\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<TD>\n";
$sql2="SELECT * FROM attributs_produits order by id";
$result2 = mysql_query($sql2);
echo "<table cellpadding=\"0\" width=\"100%\" cellspacing=\"0\">\n";
$temp=1;
while($row2 = mysql_fetch_array($result2))
{
$productid = $row2["id"];
if ( $temp == 1 )
{
echo("<tr>");
}
$photos=$row2[0];
//echo "<tr>\n";
echo "<td valign=\"top\" class=\"texte\"><b><nobr>".$row2["nom_".$_SESSION["lang"].""]." :</b></nobr></td>\n";
echo "<td><input type=\"hidden\" name=\"attribut_".$row2["id"]."\" value=\"".$row2["id"]."\">";
$sql5="SELECT * FROM attributs_produits_details where id_attribut=".$row2["id"]." order by id_attribut";
$result5 = mysql_query($sql5);
//-----------------------------------------------------------
echo "<select name='attribut_details_".$row2["id"]."'>\n";
echo "<option value=\"0\">".panier_74."</option>\n";
while($row5 = mysql_fetch_array($result5))
{
echo "<option value=\"".$row5["id"]."\">".stripslashes($row5["nom_".$_SESSION["lang"].""])."</option>\n";
}
echo "</select><BR><BR>\n";
if ( $temp == 2 ) { echo("</tr>"); $temp = 0 ;}
$temp++;
}
echo "</TABLE>\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<TD align=\"center\">\n";
echo "<input type=\"submit\" name=\"go_recherche\" value=\"".panier_77."\">\n";
echo "</form>\n";
echo "</TD>\n";
echo "</TR>\n";
echo "</TABLE>\n";
En espérant que vous pourrez m'aider.Merci!