我使用来自 php 表单的 PDO 连接在 mysql 中收集用户选择的“文本”作为数组,假设有 3 个带有名称的复选框 1- 苹果 2- 香蕉 3-樱桃
In DB stored values are as per shown apple,banana,cherry
What i want : I want to display "Apple" users in certain "/offer.php" page while i am using SELECT query and it's not working i am using pure php mvc framwork.
In Controller i done this
public function offer(){
$this->view->title = User Selection;
$this->view->offerUser = $this->model->offerUser();
$this->view->render('dashboard/offer');
}
In Model I done this
public function offerUser()
{
return $this->db->select('SELECT * FROM users WHERE selection = apple ORDER BY points DESC ');
}
In View i done this
<?php
foreach($this->offerUser as $key => $value) {?>
<tbody>
<tr>
<td></td>
<td><strong><?php echo $value['selection']?></strong></td>
</tr>
The issue is i am not able to select "Text" from stored array with model and even not able to display selection in "View" user end page.
此代码格式在选择或比较单个数字时工作正常,但在文本数组时失败。
请帮我解决这个问题,我真的很感激我是文本数组获取方面的新手。
希望有人能尽快回答我的问题....
问候, 詹姆斯
最佳答案
查询无效:在 apple 周围使用单引号
public function offerUser()
{
return $this->db->select("SELECT * FROM users WHERE selection = 'apple' ORDER BY points DESC ");
}
关于php - 如何从mysql数组文本中选择并比较,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29046767/