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

[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
#2

[eluser]rogierb[/eluser]
arrays cannot be passed through an url, just use 2 variables

echo site_url(‘jbcontroller/applyjob/’.$info_var1.’/’.$info_var2);
#3

[eluser]aamiraziz[/eluser]
its working

thanks alot Tongue
#4

[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()

So you would do the following:

$array = array(
'jbcontroller' => 'applyjob',
'cvid' => $x,
'jbid' => $jobid
);

Tbh I would use the method rogierb says. Its just nicer.




Theme © iAndrew 2016 - Forum software by © MyBB