Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.