jointure deux table et moteur de recherche
Posté : 29 déc. 2012, 11:17
bonjour je recherche à faire une jointure entre la table annonce et la table im_annonce qui contient les image des annonces.
// montage du critère
$where = array();
if ( ! empty($_SESSION['recherche'])) {
foreach($_SESSION['recherche'] as $field => $value) {
if (($field !== 'prix_min') && ($field !== 'prix_max')) {
$where[] = "$field = '".mysql_real_escape_string($value)."'";
}
}
}
if (isset($_SESSION['recherche']['prix_min'])) {
$where[] = 'prixb BETWEEN '.$_SESSION['recherche']['prix_min'].' AND '.$_SESSION['recherche']['prix_max'];
}
$target_page = "search-val.php";
$sql_where = (empty($where)) ? null : 'WHERE '.implode(' AND ', $where);
$result=mysql_query ('SELECT * FROM annonce '.$sql_where) or die(mysql_errno().' :: '.mysql_error());
$anno = mysql_num_rows($result);
et remplacer par une jointure et sortir les photos en tableau x colonne x ligne<?PHP
$requete=mysql_query("SELECT annonce.idA,im_annonce.id_gal FROM annonce LEFT JOIN im_annonce ON annonce.idA=im_annonce.id_gal limit 0,1")
or die (mysql_error ());
// Affiche le contenu
while ($row = mysql_fetch_array ($requete)) {
miniature('image_annonce/'.$row['gal'].'', 150, 100);
echo"<img src='MINI11image_annonce/".$row['gal']."' border='0'><br />";
echo"$row['prixb' ";
}
?>