【问题标题】:display total number of clients product显示客户产品总数
【发布时间】:2014-06-03 08:52:02
【问题描述】:

您好,我在向客户端显示附加产品的数量而不是数据库中的产品总数时遇到问题。

这是我的代码

<div class="span2 action-nav-button">

                    <a href="<?php echo base_url();?>index.php?client/product">

                    <img src="<?php echo base_url();?>template/images/icons/product.png" />

                    <span><?php echo get_phrase('manage_product');?></span>

                    <span class="label label-blue">

                        **<?php echo $this->db->count_all_results('product');?>**

                    </span>

                    </a>

                </div>

如您所见,它显示了 297 个产品(总计),而不是预期的 7 个。我需要修改这一行( db->count_all_results('product');?>) 以显示正确的数字吗?提前谢谢你!

-image-> http://postimg.org/image/bb1ce26nv/

【问题讨论】:

标签: codeigniter


【解决方案1】:

使用num_rows():

$productsQuery = 'SELECT * FROM product WHERE clientid = "SOME_CLIENT_ID" ';
$query = $this->db->query($productsQuery);

echo $query->num_rows();

当然,将clientid 替换为产品表中的实际字段。或者调整请求以仅获取您想要的客户的产品。

【讨论】:

  • 感谢您的评论! :) 我不是开发人员,但我正在尝试修复,因为缺少开发人员 :) 我在数据库中看到我的表,它有客户端和产品 - 在我的文件中,我在 Views 文件夹仪表板中有一个文件,我猜这是一个常见的每个人的文件。所以我想知道如何修改这个公共文件
  • 我想您必须找到正确的 SQL 请求,并将您粘贴在问题中的 PHP 代码替换为我提供给您的代码(使用正确的请求)。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-01-06
  • 2023-01-22
  • 1970-01-01
  • 1970-01-01
  • 2020-02-25
  • 2022-06-12
相关资源
最近更新 更多