[eluser]Samus[/eluser]
[quote author="mirag3" date="1333517029"]with your code i getting this.
Code:
Parse error: syntax error, unexpected T_PAAMAYIM_NEKUDOTAYIM, expecting '(' in D:\xampp\htdocs\kakobikes_portal1\application\models\news_model.php on line 5
[/quote]
model:
Code:
class News_model extends CI_Model {
function __construct()
{
parent::__construct();
}
function Get_news($idn)
{
$q = $this->db->get_where('portal_news', array('id_news' => $idn));
if($q->num_rows() > 0) :
return $q->row();
else :
return false;
endif;
}
}
Is that better?
And on your code, you're returning it with result(), which returns an array of objects. You're going to need to foreach() your results.
So the view would be something like:
Code:
<?php foreach($query as $q) {
echo $q->news_name; ?>
}
?>
If you're just returning one row from your database, i'd suggest you use row() as it returns just a single row object, so you wouldn't need to use the foreach, like in my example above.
Also you don't need to use $data= $this->uri->segment(3);
Especially not in your model, $idn in your controller is your third URI.
News is 1st
show_news is 2nd
$idn is 3rd
So all you need to do is pass $idn from your controller unto your model method, like I have done above.