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
https://forums.phpfreaks.com/topic/242963-php-mysql-count-help/
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.