<?php
session_start();
include "config.php";
if(isset($_POST['sub'])) {
if(!empty($_POST["column"])) {
$a = $_POST['column']; // column name
} else {
$a ="";
echo "please click on the right input";
}
$r="select '".$a."' , count(*) as '".$a."' from emc_leadgen group by '".$a."' ";
$t=mysql_query($r);
if (!$t)
{
$message = 'ERROR:' . mysql_error();
return $message;
}
else
{
$i = 0;
?>
<html xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns="http://www.w3.org/TR/REC-html40">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
WELCOME <?=$_SESSION['user']?></br>
<title> emc promo 1</title>
<meta http-equiv="Content-type" content="text/html;charset=utf-8" />
</head>
<body>
<?PHP
echo '<html><body><table><tr>';
while ($i < mysql_num_fields($t))
{
$meta = mysql_fetch_field($t);
echo '<td>' . $meta->name . '</td>';
$i = $i + 1;
}
echo '</tr>';
$i = 0;
while ($row = mysql_fetch_row($t))
{
echo '<tr>';
$count = count($row);
echo $count;
$y = 0;
while ($y < $count)
{
$c_row = current($row);
echo '<td>' . $c_row . '</td>';
echo "</br>";
next($row);
$y = $y + 1;
}
echo '</tr>';
$i = $i + 1;
}
echo '</table></body></html>';
mysql_free_result($t);
}
}{echo "there is no data";}*/
}
?``>
</body>
</html>
// 我在查询中使用 COUNT .........在我的结果中,我得到了一个数组格式,但我需要数据库中的唯一值。它将计算数据库中的值的数量,然后显示它就像我在下面写的一样,我需要这个结果 new delhi=4 ranchi=2 faridabad=3 但我得到 city = 9 //