Jump to content

php mysql count help


ctcp

Recommended Posts

 

<?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

 

Link to comment
Share on other sites

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." ;?> 

Link to comment
Share on other sites

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

Link to comment
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.