Welcome Guest, Not a member yet? Register   Sign In
Passing of parameters
#11

[eluser]Nikhil Vijayan[/eluser]
if you want to pass the data to controlle when the FORM is submitted , the way to do it is like

Code:
<form name="form1">

<input type="hidden" name="var_name" value="var_value">

<input type="submit" name="submit" value="submit_button_value">
</form>

so u will get the data in controller when the submit button is clicked

as
Code:
$var_name = $_POST['var_name'];

or in ci way
Code:
$var_name = $this->input->post('var_name');

also there is alterantive way by passing it thru url .
#12

[eluser]crumpet[/eluser]
what you called your form in your second post doesn't look like a form
...
there are no form elements
which means you can't use the hidden form .. unless you actually have a form

I thin you need to use the url option
you make the function your linking to take the id as a parameter and then dynamically generate the link to be
site_url('controller/function/'.$quote['QUOTE_NO']
#13

[eluser]GrootBaas[/eluser]
Thanks for your input....

How would I brake the parameter away in the controller then?
#14

[eluser]crumpet[/eluser]
You can store it in a session variable and access it later... but I would recommend doing the url thing juding by what I think your trying to accomplish.

Thats how I pass ID numbers around in all my code.
#15

[eluser]bluepicaso[/eluser]
This seems old but i need help.
I've a loop on a view that generates name of the main categories
i want if someone clicks on it it should show the list of products under it..
Initially when i used raw php...it was clear to me

below it the raw php code, that shows what i want to do
Code:
<?php
while($row = mysql_fetch_array($result))
{
?>
<a href="mypage.php?id='&lt;?=$row[ID]?&gt;'"> &lt;?=$row['category_name']?&gt;</a>
&lt;?php
}
?&gt;
In this i can pass the value id as a parameter...
But please help to understand that how should i do it with CI
i have something like this
Code:
<td>
                        &lt;?php
                            foreach($result as $row)
                            {
                                echo $row->main_cat."<br>";
                            }
                        ?&gt;
                    </td>
I know i need topass value to controller but i dont know hoe to do it...
Please help Smile
#16

[eluser]crumpet[/eluser]
Your controller needs to have a function that takes an argument like $id i

function my_function($id){
//use the id to fetch a db entry
}

then you pass the argument as the last component of the url eg.
www.example.com/my_controller/my_function/id
#17

[eluser]bluepicaso[/eluser]
Smile thanx actully i discovered a problem in my htaccess file....there was something that was hindering it.

well could you please tell me how to send the data from the controller function to the model....Please help
#18

[eluser]crumpet[/eluser]
when you call a model function just pass whatever data you want to it as a parameter. so like

model:
function get_entry($id){
//access db and return entry
}
controller:
function my_function($id){
$entry = $my_model->get_entry($id)
// pass entry to the view to display it
}
#19

[eluser]bluepicaso[/eluser]
Wow thanx a lot....That was really helping..
Actually i"m new to Ci i worked on raw PHP....so u know


Smile




Theme © iAndrew 2016 - Forum software by © MyBB