php在MYsql中查询的有关问题?
时间:2021-07-01 10:21:17
帮助过:30人阅读
php在MYsql中查询的问题??
我想在数据中根据某个值查询对应的值.例:知道user的值然后显示pwd的值。我在phpamdin里面测试的代码是:
$sql = 'SELECT pwd'
. ' FROM `appdata` '
. ' WHERE user = \'jimmy@qq.com\' LIMIT 0, 30';
但是加在php文件里面执行总是不成功。
下面是我的代码,怎么修改呢?
include_once "logindatabase.php";
$cmd = mysql_query(SELECT * FROM appdata WHERE user =jimmy@qq.com);
$rec = mysql_fetch_array($cmd);
echo $rec[Pwd];
?>
谢谢大家~
------解决方案--------------------
include_once "logindatabase.php";
$cmd = mysql_query('SELECT * FROM appdata WHERE user="jimmy@qq.com"');
$rec = mysql_fetch_array($cmd);
//while($rec = mysql_fetch_array($cmd))
echo $rec['Pwd'];
?>