hoanghad
14-02-2007, 08:31
em có 2 table ,1 dòng trong table 1 có liên quan đến n dòng trong table 2, em muốn echo 1 dòng trong table 1 và n dòng trong table 2, và lặp lại. nhưng vòng lặp sau chỉ lặp 1 lần rồi stop. các bác có biết lỗi chỗ nào ko?
<?php include("13.02/dbconnect.php");
$query = "select *from thuonghieu order by code desc ";
$result = mysql_query($query) ;
if (!$result)
{die("Xin loi! Chung toi chua cap nhat thong tin".mysql_error($conn));}
while ($row = mysql_fetch_array($result))
{
echo "$row[2]";
$a=$row[1];
echo "<img src=13.02/upload/up".$row[5]." width=170 height=195 border=0>";
echo "$row[3]";
echo "$row[4]";
$query = "select model.thuonghieu ,model.model, model.khanangcan, model.dochia, model.usd, model.ghichu, thuonghieu.tuychon from model, thuonghieu where model.thuonghieu=thuonghieu.thuonghieu order by id desc ";
$result = mysql_query($query) ;
if (!$result)
{die("Xin loi! Chung toi chua cap nhat thong tin".mysql_error($conn));}
while ($row = mysql_fetch_row($result))
{
if ($a==$row[0])
{
echo "$row[1]";
echo "$row[2]";
echo "$row[3]";
echo "$row[4]";
echo "$row[5]";
}
}
}
?>
cám ơn các bác!
<?php include("13.02/dbconnect.php");
$query = "select *from thuonghieu order by code desc ";
$result = mysql_query($query) ;
if (!$result)
{die("Xin loi! Chung toi chua cap nhat thong tin".mysql_error($conn));}
while ($row = mysql_fetch_array($result))
{
echo "$row[2]";
$a=$row[1];
echo "<img src=13.02/upload/up".$row[5]." width=170 height=195 border=0>";
echo "$row[3]";
echo "$row[4]";
$query = "select model.thuonghieu ,model.model, model.khanangcan, model.dochia, model.usd, model.ghichu, thuonghieu.tuychon from model, thuonghieu where model.thuonghieu=thuonghieu.thuonghieu order by id desc ";
$result = mysql_query($query) ;
if (!$result)
{die("Xin loi! Chung toi chua cap nhat thong tin".mysql_error($conn));}
while ($row = mysql_fetch_row($result))
{
if ($a==$row[0])
{
echo "$row[1]";
echo "$row[2]";
echo "$row[3]";
echo "$row[4]";
echo "$row[5]";
}
}
}
?>
cám ơn các bác!