问题
using form post method i need to pass a value of numID
to a controller
for example assigning a value to numID
inside view,
$numID= 25;
i need to use value of numID
in a controller and assign that to temp
variable. so i use following line of code,
$temp= $_POST[numID];
but its unable to get the exact value. Please help me on this. If have any other alternate way please let me know.
回答1:
Here is an example of sending info from view to the controller:
View:
<?php echo form_open('invoice'); ?>
<?php echo validation_errors(); ?>
<?php echo form_input('order_num', $this->input->post('order_num')); ?>
<?php echo form_submit('submit','submit'); ?>
<?php echo form_close(); ?>
Controller:
public function invoice()
{
$order = $this->input->post('order_num');
$this->General_Model->get_customer_order($order);
}
Model:
function get_customer_order($order)
{
. . .
$this->db->where('client_orders.id', $order);
$result = $this->db->get('client_orders');
. . .
}
Note we are using the input name and id as = "order_num"
Then we ask the controller to find it as $this->input->post('order_num');
来源:https://stackoverflow.com/questions/33675595/how-to-pass-a-value-of-a-variable-from-view-to-controller-in-codeigniter