Welcome Guest, Not a member yet? Register   Sign In
Why to catch a variable in View to controller
#1

[eluser]ludo31[/eluser]
Hello ,
it's a real problem , how to catch a simple variable in view to controller . I send this variable by link in php it is possible but I don't know the same in Codeigniter :

for example

when We try to send 2 variables in php here nom and prenom we make like that :

Quote:<a href="bonjour.php?nom=Dupont&amp;prenom=Jean">Dis-moi bonjour !</a>


so when we try to catch them we do that :

Code:
&lt;?php
if (isset($_GET['prenom']) AND isset($_GET['nom'])) // On a le nom et le prénom
{
echo 'Bonjour ' . $_GET['prenom'] . ' ' . $_GET['nom'] . ' !';
}
else // Il manque des paramètres, on avertit le visiteur
{
echo 'Il faut renseigner un nom et un prénom !';
}
?&gt;

so I don't know how to make that in code igniter , I try to see the doc and I think we can use anchor for the link

Code:
echo anchor('news/local/123', 'My News', array('title' => 'The best news!'));

so when we try to send an array

Code:
$atts = array(
              'width'      => '800',
              'height'     => '600',
              'scrollbars' => 'yes',
              'status'     => 'yes',
              'resizable'  => 'yes',
              'screenx'    => '0',
              'screeny'    => '0'
            );

echo anchor_popup('news/local/123', 'Click Me!', $atts);

how to catch the array or the value in controller ??

thanks
#2

[eluser]meigwilym[/eluser]
The user guide explains all of this. http://ellislab.com/codeigniter/user-gui...views.html

If you're having trouble with the language come back and I'll explain.

Mei
#3

[eluser]ludo31[/eluser]
[quote author="meigwilym" date="1330347679"]The user guide explains all of this. http://ellislab.com/codeigniter/user-gui...views.html

If you're having trouble with the language come back and I'll explain.

Mei[/quote]

Thanks , but please can you explain me the lats paragraph

Code:
$this->load->view('site_view',$data, true);

My problem is like this : in my controller I need one value as id in 2 functions :

// I need to use for example the title number = 079 in 2 functions

Code:
// my first function

function index(){
        
            // for eample it return 079
        $data['id']=$this->site_model->getId();

        $data['result']=$this->site_model->AllResult();
        
       $string = $this->load->view('site_view',$data, true);
    
        
    }



// my second function after passing in view file

public function envoyer()
    {
        $data['id']=$this->site_model->getId();

        $data['result']=$this->site_model->AllResult();

         etc .....
      
        
      
    }

in view


can you explain me the utility of this

Code:
$string = $this->load->view('site_view',$data, true);

and My question and my only problem is it possible to $data['id'] for all functions without passing in model for each function because they are linking ????

thanks




Theme © iAndrew 2016 - Forum software by © MyBB