按照asp的写法应该是
select top "&$num1&" from news where class='"&$class1&"'
php如果类似的话应该是
select top ".$num1." from news where class='".$class1."'
select top "&$num1&" from news where class='"&$class1&"'
php如果类似的话应该是
select top ".$num1." from news where class='".$class1."'
function list1($class1,$num1)
{
$result=mysql_query("select top '".$num1."' from news where class='".$class1."'",$link) or die("查询表失败".mysql_error()); //这里报错,帮忙看看 $row=mysql_fetch_row($result); while($row)
{
echo "<table width=300 height=22 border=0 cellpadding=0 cellspacing=0><tr><td>";
echo "·<a href=viewnews.php?id=$row[0] target=_blank>$row[1]</a> - $row[3]";
echo "</td></tr></table>";
}
mysql_close();
}
?>
Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in D:\www\news\function.php on line 6
查询表失败
这个sql语句没错.
如果这样还报错,检查你的表以及变量,给这个sql语句的变量赋具体值,然后直接在mysql执行。