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
}
精彩评论