Welcome Guest, Not a member yet? Register   Sign In
parameter passing from view to controller via anchor
#1

[eluser]Lakshminarayanank[/eluser]
Hi all... I am a fresher to CI.. using with mysql
I am facing a difficulty in passing and accessing the parameter.
here is ma code..

in a view :
$d = array('proj_id'=>$pid)
echo anchor('aims/view_project',$pid,$d)

in controller am accessing it..
function view_project()
{
echo 'project no is' .$proj_id;
}

Am getting undefined symbol proj_id error message .. i got helg up there...
pls help me...!!
#2

[eluser]danmontgomery[/eluser]
Code:
echo anchor('aims/view_project/'.$pid, 'Link');

// ...

function view_project($pid)
{
    echo 'project no is '.$pid;
}

http://ellislab.com/codeigniter/user-gui.../urls.html
#3

[eluser]Lakshminarayanank[/eluser]
No.. :-(
I am getting a warning as missing argument
and an error for using indefined variable ($pid)...
#4

[eluser]Bart v B[/eluser]
Take a look at your url..
Code:
$this->load->helper('url');
echo $this->uri->segment(2); // parameter what you need
#5

[eluser]OliverHR[/eluser]
Is as noctrum say.
#6

[eluser]OliverHR[/eluser]
In the view as noctrum say:
Code:
echo anchor('your_controller/your_function/'.$pid, 'Link text');

On the controller:
Code:
function your_function($proj_id) // check your parameters names
{
   echo 'project number:' . $proj_id;
}
#7

[eluser]Lakshminarayanank[/eluser]
thank you guys... thats superb....

and i wanna pass an argument from controller to a model...
how can i do that...?!
plz help me...!!
#8

[eluser]OliverHR[/eluser]
???
No offense man but, It could be better if you read first the documentation and a good php book.
#9

[eluser]Lakshminarayanank[/eluser]
hmmm ya.... could you pls suggest me some good books for php....
so that i can work well with codeigniter....
plz help.. as i said.. am new to this area....
#10

[eluser]OliverHR[/eluser]
Well look at this titles.

Beginning PHP5
Wrox Press

PHP 5 Power Programming
PRENTICE HALL

Object-Oriented Programming with PHP5
Packt Publishing

PHP Objects, Patterns, and Practice
Apress

Pro PHP Patterns, Frameworks, Testing and More
Apress
----------

And of course the CI docs:

http://ellislab.com/codeigniter/user-guide/




Theme © iAndrew 2016 - Forum software by © MyBB