• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
pass many same values to model

#1
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


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.