vincej Posted March 19, 2012 Share Posted March 19, 2012 HI - Can someone PLEASE help me figure out how to get my data into my Database from my form ?? I have a form which allows the user to amend the data and then upload the changes. The problem is that the data is stored in the same table under the same column name. sample from the table: puid locationid dates 1 1 1331668779 2 2 1331746700 3 3 1331746641 4 4 1331746641 5 1 1321746641 6 2 1321746641 When it comes to the form itself, the problem is that the <td> has also the same name for every date field (btw this is a CodeIgniter Form - not a lot different from standard HTML ) : foreach ($pickupdates as $item) { $theDates = explode(',', $item['TheDates']); ?> <tr align="center"> <td width="100" align="center"><?php echo $item['locationid'];?></td> <td width="100" align="center"><?php $data = array('name'=>$item['location'], 'size'=>20,'value' => $item['location']); echo form_input($data); ?></td> <td width="100"><?php $data = array('name'=>'TheDates','size'=>15,'value' =>(strftime("%a %d %b %Y",$theDates[0]))); echo form_input($data); ?></td> <td width="100"><?php $data = array('name'=> 'TheDates','size'=>15,'value' =>(strftime("%a %d %b %Y",$theDates[1]))); echo form_input($data); ?></td> <td width="100"><?php $data = array('name'=>'TheDates','size'=>15,'value' => (strftime("%a %d %b %Y",$theDates[2]))); echo form_input($data); ?></td> <td width="100"><?php $data = array('name'=>'TheDates','size'=>15,'value' => (strftime("%a %d %b %Y",$theDates[3]))); echo form_input($data); ?></td> <td width="150"> <?php echo anchor('admin/pickup_detail/deletelocation/'. $item['location'], 'Delete');?></td> </tr> <?php ;} ?> </table> <?php $data = array('name'=>'TheDates','size'=>15,'value' => $theDates[0],$theDates[1],$theDates[2],$theDates[3]); form_input($data); echo form_hidden('locationid', $item['locationid']); When the data ( TheDates) hits my query everythign fails of course. Here is the Query - I know it is flawed: function Updatelocation(){ if( isset( $_POST['locationid'] ) ) { foreach( $_POST['locationid'] as $pickupid=>$location) { $data = array( 'locationid' => db_clean($_POST['locationid']), 'dates' => db_clean($_POST['$theDates[0]']), 'dates' => db_clean($_POST['$theDates[1]']), 'dates' => db_clean($_POST['$theDates[2]']), 'dates' => db_clean($_POST['$theDates[3]']), ); $this->db->where('locationid', $locationid); $this->db->update('pudates',$data); $this->session->set_flashdata('message', 'Table Updated'); } } else echo "Update Failed"; } MANY MANY Thanks !! to the person who can help ! Quote Link to comment Share on other sites More sharing options...
cpd Posted March 19, 2012 Share Posted March 19, 2012 What is the error your receiving and why on earth are you using $this->db->xxxx? What are you trying to do there because it looks completely wrong at the minute. Quote Link to comment Share on other sites More sharing options...
vincej Posted March 21, 2012 Author Share Posted March 21, 2012 Thanks for the reply CPD - it is completely wrong so I have adopted a different approach, but I have issues there too - I will need help with a query, I will post soon Many thanks ! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.