繁体   English   中英

PHP&Mysql查询

[英]PHP&Mysql Query

我有这样的MySQL查询:

SELECT * FROM `customers` WHERE `promoted`= 1

尽管我想显示仅PROMOTED == 1的记录,但我从MySQL获得了All记录,但是1、2还是0都没有关系。

完整代码:

public function getPromoted($limit) 
    {
        $limit = $this->db->real_escape_string($limit);
        $stmt = $this->db->query("SELECT * FROM `customers` WHERE `promoted`= 1");
        while($row = $stmt->fetch_assoc())
        {   
            $this->rows[]=$row;
        }
        $stmt->close();
        return $this->rows;
    }

并显示:

    foreach($data['customers_promoted'] as $asd) 
{
        echo '<div class="row callout alert alert-info">
                        <div class="col-md-2">
                            <a href="http://localhost/aura/'.App::generateUrl($asd['title']).'/'.$asd['id_hash'].'  "><img src="'.SITE_PATH.'assets/images/show/600x400/'.$asd['image_thumb'].'" class="img-responsive" alt="'.$asd['title'].'"></a>
                        </div>
                        <div class="col-md-10">
                            <h4 class="margin-bottom-10"><a href="http://localhost/aura/'.App::generateUrl($asd['title']).'/'.$asd['id_hash'].'  ">'.$asd['title'].'</a></h4>
                            <p>'.$asd['dec_min'].'</p>
                            <span class="block">
                            <i class="fa fa-map-marker"></i> <strong>Adres: <a href="#">'.$asd['street'].'</a>&nbsp;&nbsp;</strong>
                            <i class="fa fa-phone"></i> <strong>Telefon: <a href="tel:'.$asd['phone'].'">'.$asd['phone'].'</a>&nbsp;&nbsp;</strong>
                            <i class="fa fa-envelope"></i> <strong>Email: <a href="mailto:'.$asd['email'].'">'.$asd['email'].'</a></strong>&nbsp;&nbsp;

                        </span> 
                        </div>
                    </div>
                    <hr />';
}

问题在哪里?

谢谢

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM