dropfaith Posted October 20, 2008 Share Posted October 20, 2008 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 More sharing options...
dropfaith Posted October 20, 2008 Author Share Posted October 20, 2008 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 More sharing options...
dropfaith Posted October 20, 2008 Author Share Posted October 20, 2008 im dumb i just remembered $result = mysql_query("SELECT * FROM Art"); $num_rows = mysql_num_rows($result); // Display the results echo $num_rows; Link to comment https://forums.phpfreaks.com/topic/129189-solved-group-by/#findComment-669781 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.