Jump to content

HOW do I Upload my Form Data


vincej

Recommended Posts

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 !

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.