繁体   English   中英

在此语句中添加WHERE子句

[英]adding a WHERE clause to this statement

我正在寻找将where子句添加到以下内容:

<?php foreach($this->assignments as $assignmentIndex => $assignmentArray): ?>

我基本上只希望从其中assignmentType = pdf的数据库中提取数据

任何帮助都会很棒!

谢谢

<?php foreach($this->assignments as $assignmentIndex => $assignmentArray): ?>
    <?php if(assignmentType == 'pdf') :?>
    ....
    ....
   <?php endif; ?>
<?php end foreach; ?>

好吧,您不能在foreachloop中更改sql行,但是,如果assignmentArray包含assignmenType,则可以忽略其他类型,如下所示:

if($assignmentArray['assignmentType'] != 'pdf'){
    continue; 
}

或更好一点的是:

if($assignmentArray['assignmentType'] == 'pdf'){
        // do your fancy stuff here
    }

暂无
暂无

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

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