用PHP在查询数据库时,不等于这个条件怎么写啊?

2025-02-23 07:51:36
推荐回答(1个)
回答1:

SQL语句写错了
1.下载SQLyog工具,这个工具用图形化的方式来管理Mysql,很方便的
你把你的语句放到里面执行一下
2.下载mysql手册,网上到处都是

我写了一个数据库查询的例子(数据库名为tarena,表名为test),你运行一下就好了
$link = mysql_connect('localhost', 'root', '');
if (!$link) {

die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
$result = mysql_query("SELECT * FROM tarena.test
where over='1' and showl='1' and aaa<>'aaa'
order by id desc limit 5")or die("Invalid query: " . mysql_error());
$num_rows = mysql_num_rows($result);
if($num_rows == NULL)
{
return NULL;
}
else
{

$num_fields = mysql_num_fields($result);
$fields=Array();
$i = 0;
echo "";
echo '';
while ($i < $num_fields)
{

$currfield = mysql_fetch_field($result);

echo '';

array_push($fields,$currfield->name);

$i++;
}

echo '';
echo '';
while($row = mysql_fetch_array($result)) {
foreach ($fields as $field) {
echo '';

}
}
echo '';
echo '
'.$currfield->name.'
'.$row[$field].'
';
}

?>