在加载此页面时,我想为每个类别显示两个产品,但是如果我单击一个类别类型,它将显示所有产品。
这是我的代码:
<?php
$resultspi= $con->query ("SELECT * FROM products WHERE ORDER BY id ASC");
if ($resultspi->num_rows > 0) {
while($rowpi = mysqli_fetch_array ($resultspi, MYSQL_ASSOC)) {
$id = $rowpi['id'];
$types = $rowpi['type'];
$image = $rowpi['images'];
$names = $rowpi['name'];
?>
<div class="item <?php echo $types;?>">
<a href="uploads/products/<?php echo $image;?>" data-rel="gallery[prodcuts]" title="<?php echo $names;?>" class="">
<img src="uploads/products/<?php echo $image;?>" alt="<?php echo $names;?>" class="thumb mCS_img_loaded" style="visibility: visible; opacity: 1;">
<p class="info"> </p>
<div class="overlay">
<span></span>
</div>
</a>
</div>
<?php
}
}
?>
答案 0 :(得分:1)
我使用此查询。这段代码对我有用。
data = pandas.read_csv(file, sep='\t', na_values='')
print(data)
答案 1 :(得分:0)
SELECT P.Name, rs.*
FROM (
SELECT [CustomerNo], PlanId, Rank()
OVER (Partition BY PlanId
ORDER BY [CustomerNo] DESC) AS Rank
FROM CustomerOfPlan
) rs
INNER JOIN [Plan] P ON P.Id = rs.PlanId
WHERE Rank <= 2
在此示例中,我有11个计划和16000个CustomerOfPlans,但结果 有22条记录..为什么?每个计划我需要2个CustomerOfPlan。
答案 2 :(得分:-1)
更改查询,请尝试以下操作: 选择*从产品中按ID ASC LIMIT 2排序的商品