我正在尝试使用php创建产品页面,但产品图像无法获取。我在数据库和PHP中这样做。请一些人帮助我,我不知道我使用的编码方法是严格还是错误。这是一个电子商务网站项目
<body>
<div align="center">
<h1 align="center">Organic Jus</h1>
<?php
include("conn.php");
$result=mysql_query("select * from organic") OR DIE(mysql_error());;
while($row=mysql_fetch_array($result)){
if(@$connt % 2==0){
?>
<table border="0" cellpadding="2px" width="1000px">
<?php } ?>
<td width="500"><img src="image/AlmondLove.jpg<?=$row['pic']?>"/>
<br><b><?=$row['productname']?></b><br/>
<?=$row['details']?><br/>
Price:<big style="color:green">$<?=$row['price']?></big><br/><br/>
<input type="button" value="Add to Cart"
onclick="addtocart(<?=$row['product_id']?>)"/>
</form>
</td>
<?php
@$count++;
}?>
</table>
</div>
</body>
答案 0 :(得分:0)
<html>
<head>
<style>
tr.d0 td {
background-color: #F8F8F9;
border-bottom-style: solid;
border-bottom-width: 1px;
border-color: #C5D0D9;
}
tr.d1 td {
background-color: #FFF5EC;
border-bottom-style: solid;
border-bottom-width: 1px;
border-color: #C5D0D9;
}
</style>
</head>
<body>
<div align="center">
<h1 align="center">Organic Jus</h1>
<?php
include("conn.php");
$result=mysql_query("select * from organic") OR DIE(mysql_error());;
$connt=0;
?>
<table border="0" cellpadding="2px" width="1000px">
<?
while($row=mysql_fetch_array($result)){
if($connt % 2==0){
$cls='d0';
}else{
$cls='d1';
}
?>
<td class="<?=$cls?>" width="500">
<td>
<img src="image/<?=$row['pic']?>" border="0"> <!-- path to image dir + image name from db -->
<br/>
<b><?=$row['productname']?></b>
<br/>
<?=$row['details']?>
<br/>
Price:<big style="color:green">$<?=$row['price']?></big>
<br/>
<br/>
<input type="button" value="Add to Cart" onclick="addtocart(<?=$row['product_id']?>)"/>
</td>
</tr>
<?php
$count++;
}?>
</table>
</div>
</body>
</html>