ctcp Posted July 27, 2011 Share Posted July 27, 2011 <?php require_once('hlios.php'); ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; } $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? doubleval($theValue) : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } mysql_select_db($database_hlios, $hlios); $query_Recordset1 = "SELECT city, COUNT(first_name) FROM carpets GROUP BY city"; $Recordset1 = mysql_query($query_Recordset1, $hlios) or die(mysql_error()); $row_Recordset1 = mysql_fetch_assoc($Recordset1); $totalRows_Recordset1 = mysql_num_rows($Recordset1); ?> <?php echo "There are ". $Recordset1['COUNT(first_name)'] ." ". $Recordset1['city'] ." items." ;?> <? mysql_free_result($Recordset1); ?> can sombady help me what is wrong here im using this teturial http://www.tizag.com/mysqlTutorial/mysqlcount.php Quote Link to comment https://forums.phpfreaks.com/topic/242963-php-mysql-count-help/ Share on other sites More sharing options...
Maq Posted July 27, 2011 Share Posted July 27, 2011 What's happening? Errors? Blank page? What? Quote Link to comment https://forums.phpfreaks.com/topic/242963-php-mysql-count-help/#findComment-1247925 Share on other sites More sharing options...
ctcp Posted July 27, 2011 Author Share Posted July 27, 2011 Thank you for replay No error just a message There are items. Quote Link to comment https://forums.phpfreaks.com/topic/242963-php-mysql-count-help/#findComment-1247927 Share on other sites More sharing options...
Nodral Posted July 27, 2011 Share Posted July 27, 2011 You are trying to count the result of the mysql query, rather than the arrays. Try changing your count lines to <?php echo "There are ". $row_Recordset1['COUNT(first_name)'] ." ". $row_Recordset1['city'] ." items." ;?> Quote Link to comment https://forums.phpfreaks.com/topic/242963-php-mysql-count-help/#findComment-1247931 Share on other sites More sharing options...
ctcp Posted July 27, 2011 Author Share Posted July 27, 2011 Thank you for the help i foung this way <? while($Recordset11 = mysql_fetch_array($Recordset1)){ echo "There are ". $Recordset11['COUNT(first_name)'] ." ". $Recordset11['city'] ." items."; echo "<br />"; } ?> lost 60 min from my life thank you Quote Link to comment https://forums.phpfreaks.com/topic/242963-php-mysql-count-help/#findComment-1247934 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.