Welcome Guest, Not a member yet? Register   Sign In
print product category and product in the same page
#1

[eluser]Bigil Michael[/eluser]
hi friens
i have 2 tables product category and product

i want to print the result like this

category(no.of product in that category)
eg: laptop(12)

can any one help me to write the query.

thanks in advance....
#2

[eluser]sanir[/eluser]
hi
use following code

Code:
$this->db->select('c.category_name, count(p.product_id)');
$this->db->from('tbl_product p');
$this->db->join('tbl_categroy c','p.categroy_id = c.category_id ','left');
$this->db->group_by('c.category_id');  
$query = $this->db->get();

// SELECT c.category_name, count(p.product_id)
// FROM tbl_product p
// JOIN tbl_category c ON p.category_id = c.category_id
// group by c.category_id

Thanks,
Nasir Ranta
#3

[eluser]Bigil Michael[/eluser]
thanks.




Theme © iAndrew 2016 - Forum software by © MyBB