Jump to content

Arranging Titles


ballouta

Recommended Posts

Hello

I will try to describe my problem briefly.

I have this table (Books)

 

ID    bname  author  version    language  isbn              cat

==    =====  ====    =====    ======  ====            ===

51    firstbok  aut1    1            en-fr      9786915484    biography

.... etc

 

I have around 400 books with 21 categories

 

I want to view these categories titles ONLY according to highest publications under these categories

e.g.:

 

Biography (145)

History (130)

etc...

 

thank you very much

Link to comment
https://forums.phpfreaks.com/topic/129262-arranging-titles/
Share on other sites

waaw it is working

 

I printed the categories and it is correct, but how do I print 'num' value in the while loop i am using?

<?php
$result = mysql_query(" SELECT `cat`,count(*) as num FROM `books` GROUP BY `cat` ORDER BY num DESC");
while( $row = mysql_fetch_array($result) )
{
echo "$row[cat] () <br>";
}

 

How i print number of books in each catgeory in the brackets?

thank you

Link to comment
https://forums.phpfreaks.com/topic/129262-arranging-titles/#findComment-670176
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.