Welcome Guest, Not a member yet? Register   Sign In
pass many same values to model
#1

(This post was last modified: 09-27-2017, 06:18 AM by Ali.)

Hello CI members

i need your help. first get all records in date column and display in view, After submit all date data pass to controller, they will be stored as Unix format. 
i do't know how to handle they values to model. please check my source

VIEW:
PHP Code:
<form method="post" action="convert_date_script/convert_do">
<
input type="submit" value="submit">

<?
php
foreach($get as $value_get){
    
$id $value_get['id'];
    
$start_date $value_get['start_date_license'];
?>

<p>
#<?php echo $id?> : <input type="text" value="<?php echo $start_date?>" name="date_<?php echo $id?>">
<input type="hidden" value=<?php echo $id?> name="id">
</p>
<?php
}
?>
</form> 
CONTROLLER:
PHP Code:
    public function convert_do(){
    
$count=0;
        
$id $this->input->post('id');
        
$start_date $this->input->post("date_$id");
        for(
$i=0$i<sizeof($start_date);$i++){
            
//$start_date1 = explode("_",$start_date);
            //$start_date_jmktime = jmktime($start_date);
        //$changed = $this->convert_date_script_model->convert_date($id,$start_date_jmktime);
        
$count++;
        }
        echo 
$count;
        
    } 
Reply
#2

In your case each input field has the same name. They are either called data_id or id. You need to create a input arrays
Try this
<input type="text" value="<?php echo $start_date; ?>" name="date_<?php echo $id; ?>[]">
<input type="hidden" value=<?php echo $id; ?> name="id[]">
On the package it said needs Windows 7 or better. So I installed Linux.
Reply
#3

(09-27-2017, 08:39 AM)rtenny Wrote: In your case each input field has the same name. They are either called data_id or id. You need to create a input arrays
Try this
<input type="text" value="<?php echo $start_date; ?>" name="date_<?php echo $id; ?>[]">
<input type="hidden" value=<?php echo $id; ?> name="id[]">

uh it's too good.
then what code needs in controller ?  date_$id return 0

$start_date = $this->input->post("date_$id");
for($i=0; $i<count($start_date);$i++){
$count++;
}
Reply




Theme © iAndrew 2016 - Forum software by © MyBB