Welcome Guest, Not a member yet? Register   Sign In
Need Help With Form Submission
#9

[eluser]vincej[/eluser]
HI CroxNix - Ok, I have been working on my model and have made a few changes. Firstly for the benefit of clarity I removed all the locations barr 1. Secondly I put specific 'names' into the CI form within the view. Thirdly I changed my model to reflect the changes in the form and I added a strtotime() so that the DB get UNIX date stamps. All the undeclared indexes are gone. also the POST array is now giving me all the dates from the from - all good. BUT, my update query is still not updating the DB. I think this is because with only a single pickup id ( puid ) it is trying to push 4 dates into a single row .. that isn't going to work, unless I perhaps missed something big. So ... maybe I should do an IMPLODE() on the POST array so can get them all on 1 row with 1 puid ? If I was successfull doing that then, I would not need GROUP_CONCAT() at the initial SELECT time. I would rather not do it as it could add more complexity ... but if needs must ..


I am really sorry to be a burden, but this has really befuddled me. anyway - here is my data"

POST:
Code:
Array ( [location] => Collingwood [Dates1] => Wed 31 Dec 1970 [Dates2] => Wed 31 Dec 1969 [Dates3] => Wed 31 Dec 1969 [Dates4] => Wed 31 Dec 1969 [locationid] => 4 [puid] => 4 [submit] => Save Changes )

View:
Code:
<?php
foreach ($pickupdates as $item) {
   $theDates = explode(',', $item['TheDates']);
  ?>
<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'=> 'Dates1','size'=>15,'value' =>(strftime("%a %d %b %Y",$theDates[0]))); echo form_input($data); ?&gt;</td>
    <td width="100">&lt;?php $data = array('name'=> 'Dates2','size'=>15,'value' =>(strftime("%a %d %b %Y",$theDates[1]))); echo form_input($data); ?&gt;</td>
    <td width="100">&lt;?php $data = array('name'=>'Dates3','size'=>15,'value' => (strftime("%a %d %b %Y",$theDates[2]))); echo form_input($data); ?&gt;</td>
    <td width="100">&lt;?php $data = array('name'=>'Dates4','size'=>15,'value' => (strftime("%a %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>
&lt;?php  ;} ?&gt;

</table>

&lt;?php
form_input($data);
echo form_hidden('locationid', $item['locationid']);
echo form_hidden('puid', $item['puid']);
echo "<div class=submitted>". form_submit('submit','Save Changes')."</div>";
echo form_close();


Model:

Code:
function Updatelocation(){
    foreach( $_POST as $pickupid=>$location) {
  $puid = $_POST['puid'];
  $locationid = $_POST['locationid'];  
    
    $data = array(
  'locationid' => db_clean($locationid),
  'puid' => db_clean($_POST['puid']),
  'dates' => db_clean(strtotime('Dates1')),
  'dates' => db_clean(strtotime('Dates2')),
  'dates' => db_clean(strtotime('Dates3')),
  'dates' => db_clean(strtotime('Dates4'))
    );
  $this->db->where('locationid',$locationid);
  $this->db->where('puid',$puid);
  $this->db->update('pudates',$data);
  $this->session->set_flashdata('message', 'Table Updated');
   }
  
  }


Messages In This Thread
Need Help With Form Submission - by El Forum - 03-19-2012, 11:43 AM
Need Help With Form Submission - by El Forum - 03-19-2012, 12:56 PM
Need Help With Form Submission - by El Forum - 03-19-2012, 03:00 PM
Need Help With Form Submission - by El Forum - 03-19-2012, 03:33 PM
Need Help With Form Submission - by El Forum - 03-19-2012, 03:40 PM
Need Help With Form Submission - by El Forum - 03-19-2012, 04:03 PM
Need Help With Form Submission - by El Forum - 03-19-2012, 04:15 PM
Need Help With Form Submission - by El Forum - 03-19-2012, 04:44 PM
Need Help With Form Submission - by El Forum - 03-20-2012, 12:26 PM
Need Help With Form Submission - by El Forum - 03-20-2012, 12:48 PM
Need Help With Form Submission - by El Forum - 03-20-2012, 02:06 PM
Need Help With Form Submission - by El Forum - 03-20-2012, 02:15 PM
Need Help With Form Submission - by El Forum - 03-21-2012, 01:30 PM
Need Help With Form Submission - by El Forum - 03-21-2012, 03:01 PM



Theme © iAndrew 2016 - Forum software by © MyBB