我正在尝试以表格格式获取单行和五列数据,并且我将表格列限制为最多5列。假设查询提取超过5个数据,如20或15个数据等。在一行中显示这么多数据看起来非常糟糕。我想要做的是在从表单行和五列中的数据库中获取5个数据之后。用户可以通过单击按钮而无需重新加载页面来查看同一行中的下5个数据。 就像在这个页面上一样:http://www.flipkart.com/ 这是我写的:
$connect = new mysqli("localhost", "root","") or die(mysqli_connect_error());
mysqli_select_db($connect,'db') or die(mysqli_connect_error());
$quer y= mysqli_query($connect, "SELECT * from table where name like 'Groc%'");
while ($row = mysqli_fetch_array($query)) {
if ($row['discount'] != 0) {
$local_price = ($row['discount'] / 100) * $row['price'];
$row['price'] = $row['price'] - $local_price;
} else {
$local_price = 0;
}
echo '
<td style="height=100px">
<center>
<a href="">
<img src="' . $row['image'] . '" width="150px" height="150px" />
</a>
<center>
<figcaption>
₨ ' . $row['price'] . '
</figcaption>
</center>
<center>
<figcaption>
Save: ₨ ' . $local_price . ' (' . $row['discount'] . '%)
</figcaption>
</center>
<center>
<figcaption>
In stock: ' . $row['stock'] . '
</figcaption>
</center>
</center>
<figcaption>
<center>
<button class="button button1">
<img src="../images/Add-to-cart-128.png" width="20px" height="20px">
Add to cart
</button>
<a href="">
<button class="button button2">
<img src="../images/vector_65_07-128.png" height="20px";width="20px">
Buy Now
</button>
</a>
</center>
</figcaption>
</td>
';
}
任何帮助?
提前谢谢。