1个回答
展开全部
两个SQL语句是不能相除的应该这样
mysql_select_db("你的数据库名"," 你是数据连接名");
$sql1=$result = SELECT COUNT( `sex` ) as con FROM `news` ;
$sql2=$result = SELECT COUNT( `sex` ) as con FROM `news` WHERE `sex` = '女';
$result 1=mysql_query($sql1," 你的数据连接名");
$result 2=mysql_query($sql2," 你的数据连接名");
$con1=mysql_fetch_array($result 1);
$con2=mysql_fetch_array($result 2);
echo $con1["con"]/$con2["con"];
//你要用百分比的可心像下面一样,把注释去掉就行了
//$m= $con1["con"]/$con2["con"]*100;
//echo $m."%" ;
mysql_select_db("你的数据库名"," 你是数据连接名");
$sql1=$result = SELECT COUNT( `sex` ) as con FROM `news` ;
$sql2=$result = SELECT COUNT( `sex` ) as con FROM `news` WHERE `sex` = '女';
$result 1=mysql_query($sql1," 你的数据连接名");
$result 2=mysql_query($sql2," 你的数据连接名");
$con1=mysql_fetch_array($result 1);
$con2=mysql_fetch_array($result 2);
echo $con1["con"]/$con2["con"];
//你要用百分比的可心像下面一样,把注释去掉就行了
//$m= $con1["con"]/$con2["con"]*100;
//echo $m."%" ;
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询