【发布时间】:2020-10-10 03:24:25
【问题描述】:
很抱歉打扰你们,但我一直在尽我所能从数据库中获取一些数据,但它一直显示我是空白的,所以我也得到了空白闪烁 :)
所以我需要做的是,
正如您在图片上看到的,我有一个包含重复数据的列 ownerId,这没关系,我就是这样工作的,现在我想从数据库中提取的是显示 itemId 并计算 ownerId = 的位置。
所以我的查询如下。
<table id="zctb" class="display table table-striped table-bordered table-hover" cellspacing="0" width="100%">
<thead>
<tr>
<th>#</th>
<th>Item Name</th>
<th>Item ID</th>
<th>Quantity</th>
</tr>
</thead>
<tbody>
<?php
$sql = "SELECT ownerId, itemId, count from user_item where ownerId = :editid";
$query = $dbh2 -> prepare($sql);
$query->bindParam(':editid',$editid,PDO::PARAM_INT);
$query->execute();
$result=$query->fetch(PDO::FETCH_ASSOC);
$cnt=1;
if($query->rowCount() > 0){
foreach($results as $result){
?>
<tr>
<td><?php echo htmlentities($cnt);?></td>
<td><?php echo htmlentities($result->item_name);?></td>
<td><?php echo htmlentities($result->itemId);?></td>
<td><?php echo htmlentities($result->count);?></td>
</tr>
<?php
$cnt=$cnt+1;
}
}
?>
</tbody>
</table>
但这不会返回任何东西,甚至没有在表中找到数据。
有什么想法吗?
【问题讨论】:
-
你检查了吗,如果 $editid 里有东西