开发者

adding a WHERE clause to this statement

I 开发者_如何学运维am looking to add a where clause to the following:

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

I want basically to only pull data from the database where assignmentType=pdf

any help would be great!

thanks


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


well you can't change the sql line in the foreachloop however if the assignmentArray containts assignmenType you could ignore the other types like this:

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

or somewhat nicer would be:

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜