$sql="select name,content from test where author='李四'";
怎么查询出结果
$result=mysql_query($sql);
while($row=mysql_fetch_array($result)){
echo $row['name'];
echo $row['content'];
}
输出不了结果,没有where条件,能够输出结果
此外,有些结果要这样输出
$sql="select count(*) as count from test";
$result=mysql_query($sql);
$row= mysql_fetch_array($result);
echo $row['count'];
求问高人总结一下怎样用php输出复杂sql语句
如果你没有修改数据库默认字符编码集,而你的项目中用的是其他的编码格式比如utf-8
首先,在mysql安装目录下找到my.ini这个文件,修改其中的两处地方:
[client]
port=3306
[mysql]
default-character-set=utf8
# The default character set that will be used when a new schema or table is
# created and no character set is defined
character-set-server=utf8
这个链接你可以参考一下:http://www.bitscn.com/pdb/php/200701/95607.html
你确定是因为中文的原因?会不会没有author='李四'的记录呢?如果你确定是中文,你可以把你的中文字符串用iconv转码成你数据库的编码试下,此外$row= mysql_fetch_array($result);用这个的原因是因为只有一条记录,自然就不会用while来输出了。