Re: [PHP-DB] Assistance Urgent.
Barry, > We have a field named: related_discipline which contains 1 of 12 different >disciplines. So for example we have Rail which could be in the field, or Utilities and so on.. what we need to do is know how many of each there are in the database, I am still developing my knowledge of PHP and MySql so help would be appreciated. We need to be able to display the 12 different options that could be in that field in the database and how many entries there are for each option. =check out the online manual. The function required is appropriately enough called COUNT(). In order to get the count to apply to a particular "discipline" use the GROUP BY and retrieve twelve counts (from one SELECT query). =dn -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] Assistance Urgent.
To get the options: $sql = "SELECT DISTINCT related_discipline FROM ORDER BY options"; To get the total number of options: $sql = "SELECT COUNT(related_discipline) FROM "; To get the number of entries for each option 'RAIL' for example: $sql = "SELECT COUNT(related_discipline) FROM WHERE related_discipline='RAIL' ORDER BY related_discipline"; That should do it. Russ On Wed, 12 Dec 2001 10:06:04 EST [EMAIL PROTECTED] wrote: > Hi I am new to this list and need some help with PHP and MYSQL. > > We have a database that has lots of fields in the table. What we are trying to do is >get specific > results, i will explain. > > Basicall we need to be able to retrieve the total number of records in the database >but for > individual entries. > > We have a field named: related_discipline which contains 1 of 12 different >disciplines. So for > example we have Rail which could be in the field, or Utilities and so on.. what we >need to do is > know how many of each there are in the database, I am still developing my knowledge >of PHP and > MySql so help would be appreciated. We need to be able to display the 12 different >options that > could be in that field in the database and how many entries there are for each >option. > > I would truly appreciate if someone could assist me here. > > With kindest regards > > > Barry Zimmerman > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] > #---# "Believe nothing - consider everything" Russ Michell Anglia Polytechnic University Webteam Room 1C 'The Eastings' East Road, Cambridge e: [EMAIL PROTECTED] w: www.apu.ac.uk/webteam www.theruss.com #---# -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] Assistance Urgent.
Hi I am new to this list and need some help with PHP and MYSQL. We have a database that has lots of fields in the table. What we are trying to do is get specific results, i will explain. Basicall we need to be able to retrieve the total number of records in the database but for individual entries. We have a field named: related_discipline which contains 1 of 12 different disciplines. So for example we have Rail which could be in the field, or Utilities and so on.. what we need to do is know how many of each there are in the database, I am still developing my knowledge of PHP and MySql so help would be appreciated. We need to be able to display the 12 different options that could be in that field in the database and how many entries there are for each option. I would truly appreciate if someone could assist me here. With kindest regards Barry Zimmerman -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]