![]() |
how can i pass array from view to controller ? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: how can i pass array from view to controller ? (/showthread.php?tid=20315) |
how can i pass array from view to controller ? - El Forum - 07-06-2009 [eluser]aamiraziz[/eluser] i am working on job portal.. i need to pass the JobID & CVID from view to controller. how can i do that ??? i am trying this. $info = array( "cvid" => $x, "jbid" => $jobid ); // Apply Using this CV echo "<td>"; echo "<li class='register'><a href="; echo site_url('jbcontroller/applyjob/'.$info.'/'); echo">Apply by this CV</li>"; echo "</td>"; how can i get the values of these variables in controller file ?? i am trying this.. // Apply This Job function applyjob($id1){ $y = $id1['cvid']; // cvid $z = $id1['jbid']; // JobID $data = $this->jbmodel->mapplyjob($z, $y); // (jobid, cvid) redirect('welcome/app_home'); } but the values of these varibles are not availible in model file.. what can be the problem? ERROR that i am receiving is: A Database Error Occurred Error Number: 1452 Cannot add or update a child row: a foreign key constraint fails (`findjobspk/apjob`, CONSTRAINT `apjob_ibfk_5` FOREIGN KEY (`JobID`) REFERENCES `job` (`JobID`) ON DELETE NO ACTION ON UPDATE CASCADE) INSERT INTO apjob(JobID, CVID, Ajdt) VALUES ('A', 'A', '2009-07-06') Thanks how can i pass array from view to controller ? - El Forum - 07-06-2009 [eluser]rogierb[/eluser] arrays cannot be passed through an url, just use 2 variables echo site_url(‘jbcontroller/applyjob/’.$info_var1.’/’.$info_var2); how can i pass array from view to controller ? - El Forum - 07-06-2009 [eluser]aamiraziz[/eluser] its working thanks alot ![]() how can i pass array from view to controller ? - El Forum - 07-06-2009 [eluser]adamp1[/eluser] Well you can pass a simple an array if you really needed. But its maybe not the best thing to do and definitely not the cleanest. Code: $this->uri->assoc_to_uri() Tbh I would use the method rogierb says. Its just nicer. |