• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Image not update(in database image update blank value)

#1
[eluser]Rocky Mehta[/eluser]
Model page:
Code:
function update_chair($filename)
{
$this->load->database();
$data = array(
   'chair_type' => $this->input->post('chair_type'),
   'chair_image' => $filename
  );
$this->db->where('chair_id', $this->input->post('chair_id'));
$this->db->update('venue_chair',$data);
}
function general()
{
  $data['mchair_id']['value'] = 0;
  $data['chair_type'] = array('name'=>'chair_type','style'=>'width:300px');
  $data['chair_image'] = array('name'=>'chair_image');
  
return $data;
}
view page:
Code:
<tr valign='top'>
   <td>Chair Image</td>
   <td colspan="2">
    &lt;?php echo form_upload('userfile',$chair_image['value']);?&gt;
    &lt;?php
if((int)$mchair_id>0)
{
          echo "<a href='../../../images/".$chair_image[' target='_blank'>View Image</a>";
}
?&gt;
    </td>
</tr>
controller page:
Code:
function main($chair_id = 0)
{
$this->load->model('venue_chair_model');
$data = $this->venue_chair_model->general();
if ($this->input->post('save'))
{
  if ($this->input->post('chair_id'))
  {
   $this->venue_chair_model->do_upload();
   $this->venue_chair_model->update_chair($_FILES['userfile']['name']);
   echo "Data Updated Successfully";
     redirect('http://localhost/venue/index.php/venue_chair/update/');
  }
  else
  {
   $this->venue_chair_model->do_upload();
   $this->venue_chair_model->insert_chair($_FILES['userfile']['name']);
   echo "Data Inserted Successfully";
  }
}
if((int)$chair_id>0)
{
  $query = $this->venue_chair_model->get($chair_id);
  $data['mchair_id']['value']=$query['chair_id'];
  $data['chair_type']['value'] = $query['chair_type'];
  $data['chair_image']['value']=$query['chair_image'];
}
$this->load->view('venue_chair_view',$data);
}
  
function update($chair_id = 0)
{
$this->load->model('venue_chair_model');
$data = $this->venue_chair_model->general();
$data['query'] = $this->venue_chair_model->getall();  
$this->load->view('venue_chair_update',$data);
}
At the update time if no changes in image field(chair_image field) value blank update blank in database.
please gave me solution how can i update a old value which i m fetched from database(if i am not changes that field).


Messages In This Thread
Image not update(in database image update blank value) - by El Forum - 02-29-2012, 03:04 AM
Image not update(in database image update blank value) - by El Forum - 02-29-2012, 03:33 AM
Image not update(in database image update blank value) - by El Forum - 02-29-2012, 03:59 AM
Image not update(in database image update blank value) - by El Forum - 02-29-2012, 05:21 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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