Count distinct records using MySQL PHP
Count distinct records using MySQL PHP
Count distinct records using MySQL PHP
This tutorial shows you how to count unique records with MySQL and display it using PHP.
This line
count(<COLUMN_NAME>) AS count_me
simply means that the count value is assigned to variable count_me and we can ECHO it using
$row['count_me']
Complete code is displayed below. Here i am using connect.php which contains the usual connecting logic to MySQL.
{column_name} refers to your COLUMN NAME
{table_name} refers to your TABLE NAME
include("connect.php"); $sql = "SELECT <COLUMN_NAME>, count(<COLUMN_NAME>) AS count_me FROM <TABLE_NAME> GROUP BY <COLUMN_NAME>"; $rsd = mysql_query($sql)or die("None"); while ($row = mysql_fetch_array($rsd)) { echo $row['<TABLE_NAME>']."(".$row['count_me'].")<p>"; }Count distinct records using MySQL PHP,
Incoming search terms:
- mysql count specific records php (4)
- mysql count distinct records (3)
- mysql count unique records (3)
- php mysql count records (2)
- php mysql record count (2)
- mysql php count unique records (2)
- MySQL Count Distinct Values (2)
- sql count distinct line (2)
- how to display content of a column using distinct in php (1)
- how to creat a voting countin php & db (1)
- how to count votes in PHP Mysql (1)
- how to count the table values in mysql tutorial how display in php (1)
- how to count specific data of mysql using jsp (1)
- how to count a row of a table using php where (1)
- tsql record counts in fields (1)
- how to display record based on group by in php (1)
- how to display similar value from an array in php (1)
- how to display sql count value in php (1)
- how to monitor values in a row in php (1)
- how to print count(*) in php (1)
- how to use count distinct for a column value in a table using php code (1)
- ms sql count records (1)
- how to count a field based on a certain value in sql (1)
- group and count csv php (1)
- distinct count mysql to a variable (1)
- count of distinct records in table (1)
- count record with specific filed valu (1)
- count records from sql database and display in textbox (1)
- count the specific values in MySQL (1)
- count the value in new column in mysql query (1)
- count unique value online (1)
- count unique values mysql (1)
- counting distinct values in a column in SQL 2012 (1)
- counting similar records in mysql (1)
- counting two fields php mysql tutorial (1)
- DATEDIFF of distinct records (1)
- display count in sql (1)
- DISPLAY COUNT OF ROWS IN TITLE (1)
- display count records as column value in tsql (1)
- displaying count of rows with a specific value sql (1)
This is the simplest code to select and display records from MySQL database table and display in PHP.
$cn=mysql_connect($db_host,$db_user,$db_password) or die(mysql_error());
mysql_select_db($db_name,$cn) or die(mysql_error());
$sql = “SELECT field_name FROM table_name”;
$rs = mysql_query($sql) or die(mysql_error());
while($row = mysql_fetch_array($rs)){
echo $field_name = $row[“field_name”];
echo “”;
}
mysql_free_result($rs);
Thanks for the post, No links allowed here please submit links or tutorials you have using our http://mistonline.in/wp/submit-script/ option.
Great tutorials. Really helpful information.
Thanks for publishing.