Welcome Guest, Not a member yet? Register   Sign In
how request id
#1

[eluser]Rodrigo Berlinck[/eluser]
hi,
I'm trying to make a request of an id, for example, lists topics of a blog a blog and when I click it shows the view of the blog, so I need to pass the id, but as I will do the request in the controller?

$this->db->where('id'); ?
#2

[eluser]Bart v B[/eluser]
[quote author="Rodrigo Berlinck" date="1270499562"]hi,
$this->db->where('id'); ?[/quote]

Does it come from an url?
Then you need to use the uri class Wink

Then it should be something like:

Code:
<?php
$this->db->where('id',$this->uri->segment(3) );

?>

You don't need it to do it from the controller, i prefer to do it in my model.
#3

[eluser]Rodrigo Berlinck[/eluser]
right, thanks for help!
#4

[eluser]Mischievous[/eluser]
Just a little FYI

Code:
$ID = $this->uri->segment(3);
$this->db->where('id', $ID);
$result = $this->db->get('blog');
if($this->db->count_all_results() > 0)
{
$blog = $result->result_array();
$blog = $blog[0];
return $blog;
} else {
show_error('No blog was found with this ID');
}
#5

[eluser]Bart v B[/eluser]
Sorry made a little mistake...

I have edited my post, first you say 'id', $this->uri->segment()
But i forgotten to post it.




Theme © iAndrew 2016 - Forum software by © MyBB