par
spidercrash » 21 avr. 2010, 17:51
cela ne marche toujours pas voici le code total de mon script biensur modifié, autant pour moi se n'etait pas ID mais id_img
<?php
include 'php/connect.php';
$sql= "SELECT annonces.region , annonces.titreannonce , annonces.descriptionannonce , annonces.numannonce , annonces.prix , annonces.date , images.miniature, images.id_img
FROM annonces
LEFT JOIN images ON images.numannonce = annonces.numannonce
WHERE annonces.categorie = 'divers'";
$req= mysql_query($sql) or die ('erreur sql §<br />'.$sql.'<br />'.mysql_error());
//Ta boucle
$i=0;
while($data=mysql_fetch_array($req))
{ // ici la boucle qui permet d'effectuer la recherche
$numannonce = $data['numannonce'];
?>
<table>
<tr>
<td class="titreannonce" colspan="2"><a href="test.php?annonces=<?php $numannonce ?>"><?php echo $data ['titreannonce']; ?></a></td>
</tr>
<tr>
<td class="region"><?php echo $data ['region']; ?></td>
<td class="prix"><?php echo $data ['prix'],'€'; ?></td>
</tr>
<tr>
<td class="miniature"><img src="<?php echo substr($data['miniature'],24); ?>"/></td>
<?php
$descriptionannonce = $data ['descriptionannonce'];
$descriptionannonce = substr($descriptionannonce, 0, 100 );
echo '<td class="description" >' . $descriptionannonce,'...' . '</td>';
?>
</tr>
<tr>
<td class="date"><?php echo $data ['date']; ?></td>
<td class="pseudo"><?php echo $data ['pseudo']; ?></td>
</tr>
</table>
<?php
}
mysql_free_result ($req);
mysql_close ();
?>
voici ma table annonces
CREATE TABLE IF NOT EXISTS `images` (
`id_img` int(11) NOT NULL auto_increment,
`numannonce` int(8) NOT NULL,
`image` varchar(50) NOT NULL,
`miniature` varchar(50) NOT NULL,
PRIMARY KEY (`id_img`),
KEY `numannonce` (`numannonce`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ;
et voici ma tables annonces
CREATE TABLE IF NOT EXISTS `annonces` (
`numannonce` int(8) NOT NULL auto_increment,
`departement` varchar(50) NOT NULL,
`region` varchar(50) NOT NULL,
`categorie` varchar(50) NOT NULL default '',
`typeannonce` varchar(50) NOT NULL default '',
`souscategorie` varchar(50) NOT NULL default '',
`titreannonce` varchar(50) NOT NULL default '',
`descriptionannonce` text NOT NULL,
`prix` varchar(50) NOT NULL default '',
`date` datetime NOT NULL,
`NUMUTILISATEURS` int(8) NOT NULL,
PRIMARY KEY (`numannonce`),
KEY `NUMUTILISATEURS` (`NUMUTILISATEURS`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ;
Désolé de ne pas d'avoir donnée plus de précision avant je n'était pas chez moi :p
cela ne marche toujours pas voici le code total de mon script biensur modifié, autant pour moi se n'etait pas ID mais id_img
[php]
<?php
include 'php/connect.php';
$sql= "SELECT annonces.region , annonces.titreannonce , annonces.descriptionannonce , annonces.numannonce , annonces.prix , annonces.date , images.miniature, images.id_img
FROM annonces
LEFT JOIN images ON images.numannonce = annonces.numannonce
WHERE annonces.categorie = 'divers'";
$req= mysql_query($sql) or die ('erreur sql §<br />'.$sql.'<br />'.mysql_error());
//Ta boucle
$i=0;
while($data=mysql_fetch_array($req))
{ // ici la boucle qui permet d'effectuer la recherche
$numannonce = $data['numannonce'];
?>
<table>
<tr>
<td class="titreannonce" colspan="2"><a href="test.php?annonces=<?php $numannonce ?>"><?php echo $data ['titreannonce']; ?></a></td>
</tr>
<tr>
<td class="region"><?php echo $data ['region']; ?></td>
<td class="prix"><?php echo $data ['prix'],'€'; ?></td>
</tr>
<tr>
<td class="miniature"><img src="<?php echo substr($data['miniature'],24); ?>"/></td>
<?php
$descriptionannonce = $data ['descriptionannonce'];
$descriptionannonce = substr($descriptionannonce, 0, 100 );
echo '<td class="description" >' . $descriptionannonce,'...' . '</td>';
?>
</tr>
<tr>
<td class="date"><?php echo $data ['date']; ?></td>
<td class="pseudo"><?php echo $data ['pseudo']; ?></td>
</tr>
</table>
<?php
}
mysql_free_result ($req);
mysql_close ();
?>
[/php]
voici ma table annonces
[sql]CREATE TABLE IF NOT EXISTS `images` (
`id_img` int(11) NOT NULL auto_increment,
`numannonce` int(8) NOT NULL,
`image` varchar(50) NOT NULL,
`miniature` varchar(50) NOT NULL,
PRIMARY KEY (`id_img`),
KEY `numannonce` (`numannonce`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ;[/sql]
et voici ma tables annonces
[sql]
CREATE TABLE IF NOT EXISTS `annonces` (
`numannonce` int(8) NOT NULL auto_increment,
`departement` varchar(50) NOT NULL,
`region` varchar(50) NOT NULL,
`categorie` varchar(50) NOT NULL default '',
`typeannonce` varchar(50) NOT NULL default '',
`souscategorie` varchar(50) NOT NULL default '',
`titreannonce` varchar(50) NOT NULL default '',
`descriptionannonce` text NOT NULL,
`prix` varchar(50) NOT NULL default '',
`date` datetime NOT NULL,
`NUMUTILISATEURS` int(8) NOT NULL,
PRIMARY KEY (`numannonce`),
KEY `NUMUTILISATEURS` (`NUMUTILISATEURS`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ;
[/sql]
Désolé de ne pas d'avoir donnée plus de précision avant je n'était pas chez moi :p