<?php foreach ($faq as $faq): ?>
<div class="form-group firstedit">
<label class="col-sm-2 control-label">Question : </label>
<div class="col-sm-8">
<input type="text" id="question" class="form-control remove_att" value="<?php echo $faq['faq_question'] ?>" placeholder="Enter the question" readonly="readonly" required="">
</div>
<div class="col-sm-8">
<select data-plugin-selectTwo class="form-control populate" id="category" required="required">
<?php foreach ($category as $category){ ?>
<option value="<?php echo $category['faq_category_id'] ?>"><?php echo $category['faq_category_name'] ?></option>
<?php } ?>
</select>
</div>
<div class="col-sm-2" class="edit_all">
<button type="button" class="btn btn-warning btn-sm show_edit" data-toggle="tooltip" data-placement="bottom" title="Edit"><i class="fa fa-edit"></i></button>
<button type="button" id="<?php echo $faq['faq_id'] ?>" class="btn btn-success btn-sm save_faq" data-toggle="tooltip" data-placement="bottom" title="Save" style="display: none"><i class="fa fa-floppy-o" ></i></button>
<button type="button" class="btn btn-danger btn-sm delete_faq" id="<?php echo $faq['faq_id'] ?>" data-toggle="tooltip" data-placement="bottom" title="Delete"><i class="fa fa-trash"></i> Delete</button>
</div>
</div>
<div class="form-group answer">
<label class="col-sm-2 control-label">Answer : </label>
<div class="col-sm-8 edit_answer" >
<textarea class="form-control remove_text" id="answer11" rows="5" placeholder="Type your answer..." required="required" readonly ><?php echo $faq['faq_answer'] ?></textarea>
</div>
<div class="col-sm-2">
<?php if ($faq['faq_status'] == "pending") : ?>
<button type="button" class="btn btn-danger btn-sm approve_faq" id="<?php echo $faq['faq_id'] ?>" data-toggle="tooltip" data-placement="bottom" title="Approve FAQ's"><i class="fa fa-trash"></i> approve</button>
<?php endif; ?>
</div>
</div>
<?php endforeach; ?>
我的控制器
public function not_approved() {
$category_id = $this->input->post('category_id');
$data['faq'] = $this->faq_model->not_approved($category_id);
// get the faq category
$data['category'] = $this->faq_model->get_category();
// echo "<script>alert('adadsdsa')</script>";
$this->load->view('faq/display_faq_not_approved', $data);
}
我有for循环的常见问题解答显示所有常见问题解答值,我有FAQ类别,但在单独的表中。
我想显示常见问题解答类别。上面我使用嵌套的for循环,但以错误结束。
我想在for-loop中显示嵌套for循环以显示所有类别。如何实现这个
答案 0 :(得分:2)
您使用的是
吗?<?php foreach ($faq as $f): ?>
尝试使用其他键,例如
configparser
答案 1 :(得分:1)
错误使用,键和值不能相同。
<?php foreach ($faq as $faq): ?>
<?php foreach ($category as $category){ ?>
例如,
$arr = array(1, 2, 3, 4);
foreach ($arr as &$value) {
$value = $value * 2;
}
答案 2 :(得分:0)
尝试
foreach ($faq as $intKey=>$strValue)
所以$ strValue就是你想要的元素