How to count all data in field |
[eluser]sovandy[/eluser]
Hello everybody, I have a problem with codeigniter.I am a student studying web programming. Now, I'm doing a project called Library Management System. I hope everybody can help me. My problem is that: I want to count the ID of Books that are borrowed to show in book_management.php. I know the syntax used to count the number of book_id, but I don know how to return it. Everybody can help me by mail: [email protected] Best regards, Sovandy
[eluser]bretticus[/eluser]
How 'bout me just replying here instead? You can simply use SQL to get a count. Such as Code: SELECT COUNT(*) AS borrowed_result FROM borrowed_books to get this in Code Igniter, you can use query and a way to get a query result like: Code: $query = $this->db->query('SELECT COUNT(*) AS borrowed_count FROM borrowed_books'); Alternatives might be: Code: $query = $this->db->get('borrowed_books'); ...or just... Code: echo $this->db->count_all('borrowed_books');
[eluser]manojchakri[/eluser]
echo $this->db->count_all('borrowed_books'); Nicely explained |
Welcome Guest, Not a member yet? Register Sign In |