Reputation: 11
Hello how can i like if i use substr(); do so i only get like 400 number of characters from the database out?
Upvotes: 0
Views: 3640
Reputation: 530
It too late, but this is for someone like me looking for solution
public function getDetails(){
// mytable(id,name,about,...,status)
$this->db->select(array('id', 'name', 'SUBSTRING(about,1,180) AS about', 'status'));
$result=$this->get('mytable');
return result_array();
}
Upvotes: 0
Reputation: 1691
You can use codeigniters limiter (test helper) to display only what you want
$string = "Here is a nice text string consisting of eleven words.";
$string = character_limiter($string, 400);
You can pull the entire string out of the database but only use the number of characters you need.
Or take a look at this tutorial using "left" in mysql http://net.tutsplus.com/tutorials/php/how-to-create-blog-excerpts-with-php/
Upvotes: 0