How to display search results from different categories with PHP and MySql -


i working on classifieds website, , have question retrieving search results.

my goal display number of classifieds in each category next category-names.

for instance:

  • red cars ( 821 )
  • android phones (291 )
  • notebook computers ( 929 )

what ideal way of getting these counts mysql database tables?

is write 1 query every single table in database? mean lot of queries 1 visitor, , perhaps cause performance issues?

thanks

update:

i haven't created mysql table yet, feel free recommend ideal structure if plays big role in counting.

i prefer have 1 query need.

assuming have categories table , no of classifieds products should able this:

    select c.category, count(p.id) productscount  categories c left join products p on c.id = p.category_id group c.category     order c.category 

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -