如何从选项值中将值放入mysql中? 这是我的代码来自文件" visitor_model.php"。
public function month_visitor() {
$month_query = $this->db->query('SELECT * FROM data_visitor WHERE MONTH(date)=X');
return $month_query->result();
}
这是我在文件" visitor_table.php"
中的选项代码<div class="row text-center">
<h1 id="visitor_table">Visitor Table</h1>
<form action="<?php echo site_url('month_visitor');?>" method="get">
<div>
<label for="nomor" class="col-md-2">
Month :
</label>
<div class="col-md-9">
<select name="month" class="form-control" id="month">
<option>All</option>
<option value='1'>January</option>
<option value='2'>February</option>
<option value='3'>March</option>
<option value='4'>April</option>
<option value='5'>May</option>
<option value='6'>June</option>
<option value='7'>July</option>
<option value='8'>August</option>
<option value='9'>September</option>
<option value='10'>October</option>
<option value='11'>November</option>
<option value='12'>December</option>
</select>
</div>
</div>
我想从
填充X.$month_query = $this->db->query('SELECT * FROM data_visitor WHERE MONTH(date)=X');
来自期权的价值。我怎么能这样做?
答案 0 :(得分:0)
在PHP中,只需将参数month
绑定到查询中$this->input->get('month')
:
$month_query = $this->db->query('SELECT * FROM data_visitor WHERE MONTH(date)=?', array($this->input->get('month')));