09/10/2018, 23:58
Mình muốn chia thành 2 cột hiện product làm sao? có sẵn code 1 cột
code sau đây hiển thị 1 sản phẩm rồi xuống hàng
mình muốn chia cách hiện sản phẩm của mình là 2 sản phẩm rồi xuống hàng hiện tiếp 2 sản phẩm,cứ thế...
bạn nào có thể sửa code dùm mình với,thx nhiều !!!
mình muốn chia cách hiện sản phẩm của mình là 2 sản phẩm rồi xuống hàng hiện tiếp 2 sản phẩm,cứ thế...
bạn nào có thể sửa code dùm mình với,thx nhiều !!!
function fShowNewProduct()
{
$sSQL="select * from product where iStatus>0 and iNew>0 order by iProductID desc";
$Result=mysql_query($sSQL) or die(mysql_error());
if(mysql_num_rows($Result))
{
echo "
<table width=100% bgcolor=#cccccc cellpadding=0 cellspacing=1>
<tr bgcolor=#F26464>
<td width=100% align=center class=text height=22><font color=#ffffff><b>Sản phẩm mới</b></font></td>
</tr>
<tr>
<td width=100% bgcolor=#F7FFFF>
<table width=100% class=text>
<tr>
<td height=5></td>
</tr>
";
$i=0;
while(($aRow=mysql_fetch_array($Result))and($i<10) )
{
$i++;
$sPicture="";
if(strlen($aRow['sThumbnail'])>0)
$sPicture="<a href='product_details.php?iCatID=$aRow[iCatID]&iPID=$aRow[iProductID]'><img src='$aRow[sThumbnail]' border=0></a><br>";
echo "<tr><td align=center>
$sPicture
<a href='product_details.php?iCatID=$aRow[iCatID]&iPID=$aRow[iProductID]'>$aRow[sProductName]</a>
</td></tr>
<tr><td height=5></td></tr>
";
}
echo "</table>
</td>
</tr>
</table>
<table>
<tr><td height=5></td></tr>
</table>
";
}
}
{
$sSQL="select * from product where iStatus>0 and iNew>0 order by iProductID desc";
$Result=mysql_query($sSQL) or die(mysql_error());
if(mysql_num_rows($Result))
{
echo "
<table width=100% bgcolor=#cccccc cellpadding=0 cellspacing=1>
<tr bgcolor=#F26464>
<td width=100% align=center class=text height=22><font color=#ffffff><b>Sản phẩm mới</b></font></td>
</tr>
<tr>
<td width=100% bgcolor=#F7FFFF>
<table width=100% class=text>
<tr>
<td height=5></td>
</tr>
";
$i=0;
while(($aRow=mysql_fetch_array($Result))and($i<10) )
{
$i++;
$sPicture="";
if(strlen($aRow['sThumbnail'])>0)
$sPicture="<a href='product_details.php?iCatID=$aRow[iCatID]&iPID=$aRow[iProductID]'><img src='$aRow[sThumbnail]' border=0></a><br>";
echo "<tr><td align=center>
$sPicture
<a href='product_details.php?iCatID=$aRow[iCatID]&iPID=$aRow[iProductID]'>$aRow[sProductName]</a>
</td></tr>
<tr><td height=5></td></tr>
";
}
echo "</table>
</td>
</tr>
</table>
<table>
<tr><td height=5></td></tr>
</table>
";
}
}
Bài liên quan
còn code của bạn bạn tự sửa
bạn có thể edit dùm mình chổ đó luôn được không?
Vd: $cols = 2;
Thực hiện vòng lặp,nếu khách yêu cầu 3 cột thì $cols =3 là xong.
Bạn thử test cái này xem sao nhé:
function fShowNewProduct()
{
$cols = 2;
$sSQL="select * from product where iStatus>0 and iNew>0 order by iProductID desc";
$Result=mysql_query($sSQL) or die(mysql_error());
if(mysql_num_rows($Result))
{
echo "
<table width=100% bgcolor=#cccccc cellpadding=0 cellspacing=1>
<tr bgcolor=#F26464>
<td width=100% align=center class=text height=22><font color=#ffffff><b>Sản phẩm mới</b></font></td>
</tr>
<tr>
<td width=100% bgcolor=#F7FFFF>
<table width=100% class=text>
<tr>
<td height=5></td>
</tr>
";
$i=0;
while(($aRow=mysql_fetch_array($Result))and($i<10) )
{
$i++;
$sPicture="";
if(strlen($aRow['sThumbnail'])>0)
$sPicture="<a href='product_details.php?iCatID=$aRow[iCatID]&iPID=$aRow[iProductID]'><img src='$aRow[sThumbnail]' border=0></a><br>";
echo "<tr>
for($j =0;$j<$cols;$j++){
<td align=center>
$sPicture
<a href='product_details.php?iCatID=$aRow[iCatID]&iPID=$aRow[iProductID]'>$aRow[sProductName]</a>
</td>
}
</tr>
<tr><td height=5></td></tr>
";
}
echo "</table>
</td>
</tr>
</table>
<table>
<tr><td height=5></td></tr>
</table>
";
}
}
mong sự giúp đỡ của mọi người edit code dùm mình