select count(*) as TOTAL form person where sex="人妖";
sorryis "from" not "form"
sql语句我很清楚,如何执行这条语句,怎么引用执行后的结果。
给你一个麻烦的例子: <? // $query="select * from $table where ....."; $result=@mysql_query($query); $num=@mysql_num_rows($result); ..... ?> $num 即为满足条件的纪录。
请问在表的名称(table)前加$是什么意思?
$query="select count(*) as TOTAL from person where sex='人妖'"; $result=mysql_query($query); $temp=mysql_fetch_array($result); echo $temp['TOTAL']; //输出查询结果(记录数) ~~~~~~~~~~~~~~~~~~~~~~
not "form"
<?
//
$query="select * from $table where .....";
$result=@mysql_query($query);
$num=@mysql_num_rows($result);
.....
?>
$num 即为满足条件的纪录。
$result=mysql_query($query);
$temp=mysql_fetch_array($result);
echo $temp['TOTAL']; //输出查询结果(记录数)
~~~~~~~~~~~~~~~~~~~~~~