Welcome Guest, Not a member yet? Register   Sign In
How to pass values to another page (instead of query string)
#1

[eluser]johnmiller[/eluser]
I have read that codeigniter gives facility to pass values in some other way (instead of query string).

Can you please tell me how to do that?

The below is my view page (blogview.php)

Code:
<?php $counter = count($query);?>

<table border="1">
<thead>
<tr>
<th>Id</th>
<th>Name</th>
<th>Address</th>
</tr>
</thead>
<tbody>
&lt;?php
for($i=0;$i<$counter;$i++)
{
?&gt;  
  <tr>
    <td>&lt;?php echo $query[$i]->id;?&gt;</td>
    <td>&lt;?php echo $query[$i]->name;?&gt;</td>
    <td>&lt;?php echo $query[$i]->address;?&gt;</td>
  </tr>
&lt;?php
}
?&gt;
</tbody>
</table>


I need to make 'name' as link.

When I click that, it should go to another page with the corresponding id of that name.

Its 'a href' and 'query string' in normal code.

How to do that in codeigniter?
#2

[eluser]johnmiller[/eluser]
please reply me if anybody knows the answer....
#3

[eluser]Adam Griffiths[/eluser]
You can pass the id to an url by tagging it on the end.

Example.
Code:
<a href="&lt;?php echo(">id);?&gt;" alt="">See the comments</a>

Then to see the comments for a particular post, you go to the URI for the corresponding id in the database.

Then you can reference the ID using the URI helper...like this.

Code:
$this->load->helper('uri');
$this-uri-segment(n);

Where n is the segment where you id is, so if it was index.php/blog/comments/ID it would be 3.

That's just an example script, I'm not sure what you're exactly looking to do, but it should point you in the right direction.
#4

[eluser]Colin Williams[/eluser]
The user guide covers this extensively. Give it a quick read.

If you are actually looking to pass values without displaying them at all, use cookies or session. Michael Wales has a good flashdata library for things like this.

Also, regarding the previous post, you do not need to load the URI helper to use the uri class. Again, refer to the user guide
#5

[eluser]johnmiller[/eluser]
Thanks a lot friends....




Theme © iAndrew 2016 - Forum software by © MyBB