这句 有什么有关问题么?不知道错在哪

WBOY
发布: 2016-06-13 13:21:05
原创
931 人浏览过

这句 有什么问题么?不知道错在哪

PHP code
<!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

--><?php $con = mysql_connect("localhost","root","");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("test", $con);
$sql1=$result = SELECT `a1` FROM `tab` WHERE 1;
$sql2=$result = SELECT `a3` FROM `tab` WHERE 1;
$result 1=mysql_query($sql1," $con");
$result 2=mysql_query($sql2," $con");
$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."%" ;
?>
登录后复制


------解决方案--------------------
PHP code
/*
$sql1=$result = SELECT `a1` FROM `tab` WHERE 1;
$sql2=$result = SELECT `a3` FROM `tab` WHERE 1;
$result1=mysql_query($sql1," $con");
$result2=mysql_query($sql2," $con");
$con1=mysql_fetch_array($result 1);
$con2=mysql_fetch_array($result 2);
echo $con1["con"]/$con2["con"];
*/
//太佩服你了,上面这段代码每一行都有错误!!

$sql1 = 'SELECT `a1` FROM `tab` WHERE 1';
$sql2 = 'SELECT `a3` FROM `tab` WHERE 1';
$result1=mysql_query($sql1,$con);
$result2=mysql_query($sql2,$con);
$con1=mysql_fetch_array($result1);
$con2=mysql_fetch_array($result2);
echo $con1['a1'] / $con2['a3']; <div class="clear">
                 
              
              
        
            </div>
登录后复制
相关标签:
来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板