Welcome Guest, Not a member yet? Register   Sign In
how do i send array from view to controller
#1

[eluser]Unknown[/eluser]
i am working on a form, where i upload banners, and those banners are shown at index page, i am reterieving banner path from controller, after finishing upload.
i want to send email and include links of those banners.
how could i send array that have image paths to controller
i want to send this $approved array to controller where i could be able to get these values
View file
Code:
<?php if (isset($approved) && count($approved)):
foreach($approved as $ap): ?>

  <?php if(isset($ap['thumb728'])):?>
   <div class="thumb">
     &lt;?php echo anchor('site/removeApproved/'.$ap['file'],'x')?&gt;
    <img src="&lt;?php echo $ap['thumb728']; ?&gt;" />
   </div>
  &lt;?php endif;?&gt;
  
&lt;?php endforeach;?&gt;
&lt;?php endif; ?&gt;
</div>
#2

[eluser]Jan_1[/eluser]
How about setting a checkbox and sending data as post?

Code:
echo form_open(site_url('site/removeApproved'));
$i=0;
FOREACH($fotoss AS $foto):  
$checkbox   =   array(  'name'      =>  'foto_id['.$i.']',
     'id'        =>  'checkbox',
     'value'     =>  $foto->id,
     'class'     =>  'checkbox inline',       //class example bootstrap
     'style'     =>  'margin:5px'
                                    );
echo "<img src='&lt;?=$filepath?&gt;&lt;?=$foto-&gt;name?&gt;' />";
$i++;
ENDFOREACH; ?&gt;
echo form_submit('submit', 'approve', 'class="btn"');  //class example bootstrap
echo form_close();

in model/controller:
Code:
$approvals = $this->input->post('foto_id');
Foreach($approvals AS $approval) { do something; }
#3

[eluser]Unknown[/eluser]
Thanks for help, it worked,




Theme © iAndrew 2016 - Forum software by © MyBB