我希望在以下内容中添加一个where子句:
<?php foreach($this->assignments as $assignmentIndex => $assignmentArray): ?>
我基本上只想从数据库中提取数据,其中assignmentType = pdf
任何帮助都会很棒!
感谢
答案 0 :(得分:1)
<?php foreach($this->assignments as $assignmentIndex => $assignmentArray): ?>
<?php if(assignmentType == 'pdf') :?>
....
....
<?php endif; ?>
<?php end foreach; ?>
答案 1 :(得分:0)
你不能改变foreachloop中的sql行 但是如果assignmentArray包含assignmenType 你可以忽略其他类型:
if($assignmentArray['assignmentType'] != 'pdf'){
continue;
}
或更好一点:
if($assignmentArray['assignmentType'] == 'pdf'){
// do your fancy stuff here
}