Welcome Guest, Not a member yet? Register   Sign In
Why will my Form not update ??
#1

[eluser]vincej[/eluser]
HI - The POST array which is uploading from my View looks like this:

Code:
Array
(
    [2] => 31 Dec 1969
    [3] => 31 Dec 1969
    [1] => 31 Dec 1969
    [4] => 31 Dec 1969
    [7] => 31 Dec 1969
    [5] => 31 Dec 1969
    [8] => 31 Dec 1969
    [6] => 31 Dec 1969
    [submit] => Save Changes
)


Model:
Code:
function Updatelocation(){
  
  foreach ($_POST as $key=>$value )
  {
  
  $date = strtotime($value);
  $this->db->where('puid', $key);
  $this->db->update('pudates',$date);
  }

View


Code:
<tr align="center">
<td width="100" align="center">&lt;?php echo  $item['locationid'];?&gt;</td>
   <td width="100" align="center">&lt;?php //$data = array('name'=>'location[]', 'size'=>20,'value' => $item['location']); echo form_input($data); ?&gt;</td>
   <td width="100">&lt;?php $data = array('name'=> $theIDs[0],'size'=>15,'value' =>(strftime("%d %b %Y",$theDates[0]))); echo form_input($data);?&gt;</td>
   <td width="100">&lt;?php $data = array('name'=> $theIDs[1],'size'=>15,'value' =>(strftime("%d %b %Y",$theDates[1]))); echo form_input($data);?&gt;</td>
   <td width="100">&lt;?php $data = array('name'=> $theIDs[2],'size'=>15,'value' => (strftime("%d %b %Y",$theDates[2]))); echo form_input($data); ?&gt;</td>
   <td width="100">&lt;?php $data = array('name'=> $theIDs[3],'size'=>15,'value' => (strftime("%d %b %Y",$theDates[3]))); echo form_input($data);?&gt;</td>
   <td width="150"> &lt;?php echo anchor('admin/pickup_detail/deletelocation/'. $item['location'], 'Delete');?&gt;</td>
  
</tr>


MY Model is broken. First my dates need to be converted into Unix time, then they have to update the DB.

Edit: The strtotime() is working but for some reason I can not get my data uploaded.

My syntax is clearly wrong - But I can't see where.


MANY MANY THanks for any help you might be able to give !
#2

[eluser]CroNiX[/eluser]
The $date in your update() needs to be an array with a key that is the name of the field that it's supposed to update and the value is the value.
#3

[eluser]vincej[/eluser]
CroxNix - Many Thanks, It works ! - I am impressed by the stupid mistakes I make !

One very weird behaviour the s/w is exhibiting, which I am uncertain about, is how I might amend a human readable date in the form, like "31 Aug 2011" and I do submit, but 20% of the time the amendment does not 'take' ie it comes back with the old date. So I try again, or I try on a different field and it then does work.

Is this the inadequacy of the strftime function ?

Or perhaps, because my update() is not doing a batch update but rather individual fields ?

Thanks !




Theme © iAndrew 2016 - Forum software by © MyBB