bonjour je cree un site d'annonce et je voudrai votre avis pour ma base jai creer une table image et annonce.Lors de la creation le client peut entre une imlage principale et supllmentaire.pour affichez c est annonce j ai fait un select sur l'annonce pour affichez ses attribut titre , prix...
mais je n arrive pas a obtenir que l'image principale.Je pensais faire un select sur table image avec group by et recupere l'id min en fait pas trop sur.
pouvez vous m'aidez?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
 <?php	
 // Script faisant appel aux sessions
    session_start();
include("../include/session.php");
include ("../include/connexion.php");
$description = "";
$keywords = "";
$subject = "";
$title = "";
$fakea = "";
$menu = true;
$entry="";
$publicite =false;
 
 
		$image = mysql_query('SELECT * FROM image');
		$liste_annonce = mysql_query('SELECT * FROM annonce');
 
		while( $annonce = mysql_fetch_assoc($liste_annonce) )
		{
 
		$entry.='<div class="liste">
		
		 
		 
			<table class="listeManga">
				<tr>
			<td><div>'.$annonce['date'].'<br />'.$annonce['heure'].'</div></td>
					
					<td><div><img src="image/'.$image['up_filename'].'" alt="" title="" /></div></td>
				
					<td>
						<div class="DonneSource">
						
						
								<b>titre: </b>'.$annonce['titre_annonce'].'<br />
								<b>prix: </b>'.$annonce['prix'].'<br /></td>
								
							</div>			
							<td><div>
						';
 
								$liste_typseries = mysql_query('
								SELECT distinct nom_categorie 
								FROM categorie_annonce as c,annonce as a
								where a.ref_idcateg=c.id_categorie
								and a.ref_idcateg='.$annonce['ref_idcateg']);
 
								while( $typserie = mysql_fetch_array($liste_typseries) 
							)	
								{
									$entry.=' '.$typserie['nom_categorie'].'';
								}
								$entry.='<br /></td></div></td>
								
							</div>
						</div>
					</td>
				</tr>
			</table>
		</div>';
		}
 
 
 
 
include("../include/base.php");
?>

DE PLUS JE voudrais une image par defaut si pas d'image principale.
merci.
table annonce relie a table image par 1.n.


Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
 
Structure de la table `annonce`
-- 
 
CREATE TABLE `annonce` (
  `num-annonce` smallint(6) unsigned NOT NULL auto_increment,
  `cp-annonce` tinyint(5) NOT NULL,
  `titre-annonce` text NOT NULL,
  `texte_annonce` text NOT NULL,
  `prix_annonce` decimal(10,0) NOT NULL,
  `photo-principal` text NOT NULL,
  `photo_supplementaires` text NOT NULL,
  `n-typeannonce` smallint(6) unsigned NOT NULL,
  `n-categorieannonce` smallint(6) unsigned NOT NULL,
  `id-annonceur` smallint(5) unsigned NOT NULL,
  `id-region` smallint(6) unsigned NOT NULL,
  PRIMARY KEY  (`num-annonce`),
  KEY `n-typeannonce` (`n-typeannonce`),
  KEY `n-categorieannonce` (`n-categorieannonce`),
  KEY `id-annonceur` (`id-annonceur`),
  KEY `id-region` (`id-region`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
 
-- 
-- Contenu de la table `annonce`
--

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
-- Structure de la table `image`
--
 
CREATE TABLE IF NOT EXISTS `image` (
  `up_id` int(20) unsigned NOT NULL AUTO_INCREMENT,
  `up_filename` varchar(19) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
  `up_type` varchar(250) NOT NULL,
  `up_filesize` int(10) unsigned DEFAULT '0',
  `up_mid` varchar(50) DEFAULT '0',
  PRIMARY KEY (`up_id`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=25 ;