Jump to content

[SOLVED] Group By


dropfaith

Recommended Posts

im not sure count is my best option what im trying to do is get the total number of rows in the database to display i have this working using group by for counting rows with a certain value on a move review page

There are Currently (3 Dvd) Reviews. There are Currently (1 Theatre) Reviews.

and so on but now i want to have it so it just gets all results so the above would display

There are Currently (4) Reviews.

<?php
// Make a MySQL Connection
include("../template/conf.php");
// open database connection
$connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!");
// select database
mysql_select_db($db) or die ("Unable to select database!");

	$query = "SELECT *, COUNT(*) FROM Art GROUP BY ";
	$result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());




// Print out result
while($row = mysql_fetch_array($result)){
echo "There are Currently (". $row['COUNT(*)'] .")  Artists.



";

}
?>

Link to comment
https://forums.phpfreaks.com/topic/129189-solved-group-by/
Share on other sites

CREATE TABLE `Art` (

  `loginid` int(5) NOT NULL,

  `Id` int(11) NOT NULL auto_increment,

  `Name` varchar(250) NOT NULL,

  `Medium` varchar(250) NOT NULL,

  `About` text NOT NULL,

  `Contact` varchar(250) NOT NULL,

  `Website` varchar(150) NOT NULL,

  PRIMARY KEY  (`Id`),

  UNIQUE KEY `Name` (`Name`)

) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=24 ;

Link to comment
https://forums.phpfreaks.com/topic/129189-solved-group-by/#findComment-669776
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.