Pb dans mon code php

Résolu/Fermé
enzo - 23 juil. 2009 à 15:13
Nabla's Messages postés 18203 Date d'inscription mercredi 4 juin 2008 Statut Contributeur Dernière intervention 28 avril 2014 - 23 juil. 2009 à 15:41
Bonjour,


voilà g ce code qui doit m'afficher un résultat
le pb c'est que ca m'affiche le premier et pas les autres resultat suvant de ma base

code:


<?
include ('./connect/connection.php');
?>
<html>
<head>
<title>Document sans titre</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<TABLE cellSpacing="0" cellPadding="0" width="900" background=".././immenu/allumer-cigare.jpg" height="800" border="0" >
<TBODY>
<tr>
<TD vAlign="top" width="1" bgColor="#000000"><img src=".././immenu/pixelb.gif" width="1" height="800" border="0"></TD>
<td height="800" valign="top">
<table width="150" height="768" border="0" align="left" cellspacing="0" cellpadding="0">
<tr>
<td width="150" height="19" align="center" valign="top"> </td>
</tr>

<tr>
<td width="21%" height="356" align="left" valign="top">

<? include('./menugauche.php');?>

</td>
</tr>
</table>
<table border="1" valign="top" width="750" height="72">
<?

if (isset($_GET['cat']))
{
$cat=$_GET['cat'];
}
if (isset($rub)&& isset($sousrub)&& isset($cat))
{
$sql="select nom_produit, prix_produit, descriptif_produit,images_produits from produits
where produits.num_marques ='$cat'";
$req = mysql_query($sql);
$nbrows= mysql_num_rows($req);
for ($i=0;$i<$nbrows;$i++)
{
$data= mysql_fetch_object($req);
?>
<tr><td width="132" bgcolor="ffffff"><? echo $data->images_produits?></td>
<td width="228" bgcolor="ffffff"><? echo $data->nom_produit?></td>
<td width="180" bgcolor="ffffff"><? echo $data->prix_produit?></td>
</tr>

<table width="100" border="1">
<tr>
<td><? echo $data->descriptif_produit?></td>
</tr>
</table>
</table>

<?
}
}
mysql_close();
?>
</td>
</tr>
</TBODY>
</table>
</body>
</html>

une idée?? merci
A voir également:

3 réponses

Nabla's Messages postés 18203 Date d'inscription mercredi 4 juin 2008 Statut Contributeur Dernière intervention 28 avril 2014 3 192
23 juil. 2009 à 15:21
le pb est a ce niveau la:
$req = mysql_query($sql);
$nbrows= mysql_num_rows($req);
for ($i=0;$i<$nbrows;$i++)
{
$data= mysql_fetch_object($req);
?>
tu n'as pas besoin du numrow, car tu fais du mode objet

je te conseilles de faire
<?
while ($data= mysql_fetch_object($req))
{
?>
<tr><td width="132" bgcolor="ffffff"><? echo $data->images_produits?></td>
<td width="228" bgcolor="ffffff"><? echo $data->nom_produit?></td>
<td width="180" bgcolor="ffffff"><? echo $data->prix_produit?></td>
</tr>
<?
}
?>
1
thanks thanks
so good
1
Nabla's Messages postés 18203 Date d'inscription mercredi 4 juin 2008 Statut Contributeur Dernière intervention 28 avril 2014 3 192
23 juil. 2009 à 15:41
y a pas de quoi
1