Pb dans mon code php
Résolu
enzo
-
Nabla's Messages postés 18203 Date d'inscription Statut Contributeur Dernière intervention -
Nabla's Messages postés 18203 Date d'inscription Statut Contributeur Dernière intervention -
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
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:
- Pb dans mon code php
- Code ascii - Guide
- Code puk bloqué - Guide
- Comment déverrouiller un téléphone quand on a oublié le code - Guide
- Code activation windows 10 - Guide
- Code blocks - Télécharger - Langages
3 réponses
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>
<?
}
?>
$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>
<?
}
?>