【发布时间】:2017-08-08 21:10:32
【问题描述】:
我想创建一个电子商务网站,使用 PHP 和 mySQL DB。我在下面有这段代码,我希望(如果可能的话,使用 php),在连接到 sql DB(我这样做)之后,根据 DB 表中的条目重复这个 DIV 并回显表中每个条目的数据。我找到了这个,但我不知道它是否是正确的例子:Automatically creating div's using data from a sql table
代码如下:
<div class="col-md-4 agileinfo_new_products_grid agileinfo_new_products_grid_mobiles">
<div class="agile_ecommerce_tab_left mobiles_grid">
<div class="hs-wrapper hs-wrapper2">
<img src="images/<image>.jpg" alt=" " class="img-responsive" />
<div class="hs_bottom hs_bottom_sub1">
<ul>
<li>
<a href="#" data-toggle="modal" data-target="#myModal3"><span class="glyphicon glyphicon-eye-open" aria-hidden="true"></span></a>
</li>
</ul>
</div>
</div>
<h5><a href="#"><Itemname></a></h5>
<div class="simpleCart_shelfItem">
<p><i class="item_price"><Price></i></p>
<p><i class="item_price"><Description></i></p>
<form action="#" method="post">
<input type="hidden" name="cmd" value="_cart" />
<input type="hidden" name="add" value="1" />
<input type="hidden" name="item" value="Itemname" />
<input type="hidden" name="amount" value="Price"/>
<button type="submit" class="cart">Add to cart</button>
</form>
</div>
</div>
【问题讨论】:
-
是的,这是正确的方法。从链接
-
你找到了一个很好的例子,为什么不实现它呢?
-
有点像 asp
对吧?? -
该链接是一个很好的起点,只需遍历您的数据库结果并在每次循环时用您在数据库中调用它们的任何内容替换您的字段,就像它们在您的链接中一样提供了。
-
因为我找到了几百个其他示例,但没有一个有效,所以我想问一下!
标签: php html mysql database e-commerce