计算列中相同项目的编号 [英] Count number of same item in a column

查看:71
本文介绍了计算列中相同项目的编号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好

我想计算数据库中我的表中一列中相同项目的数量。

例如我有我的专栏讲师和不同物品是好,坏

我想算一下好的数量..



你能给我一个吗?这个PHP代码..



我试过

Hello
I want to count the number of same item in a column in my table in database.
For example I have my column "lecturer" and the different items are "Good","Bad"
I want to count the number of "Good"..

Can you give me the PHP code for this..

I have tried

<?php <br mode="hold" /?>$con =
mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("db_lec", $con);
$result = mysql_query("SELECT COUNT (lecturer)FROM tbl_lec WHERE lecturer="Good"");

echo "<h1><table class="TFtable">
<tr>
	<td>Lecturer</td>
	
	</tr>";

	while($row = mysql_fetch_array($result))
	   {
	  echo "<tr>";
	  echo "<td>" . $row['lecturer'] . "</td>";
	  echo "</tr>";
	  }
	echo "</table></h1>";

mysql_close($con) 
?> 



但它无法正常工作



请帮助我


but it is not working

Help me please

推荐答案

con =
mysql_connect(localhost,root,);
if(!
con = mysql_connect("localhost","root",""); if (!


con)
{
die('无法连接:'。mysql_error());
}
mysql_select_db(db_lec,
con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("db_lec",


con);


这篇关于计算列中相同项目的编号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆