按照asp的写法应该是
select top "&$num1&" from news where class='"&$class1&"'
php如果类似的话应该是
select top ".$num1." from news where class='".$class1."'

解决方案 »

  1.   

    <?phpinclude 'conn.php';
    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();
    }
    ?>
      

  2.   

    "select top,$num1 from news where class='$class1'"
      

  3.   

    还是报错啊
    Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in D:\www\news\function.php on line 6
    查询表失败
      

  4.   

    $sql='select * from news where class='.$class1.' limit 0,'.$num1;$result=mysql_query($sql,$link) or die("查询表失败".mysql_error()); //试试这个行不行
      

  5.   

    php+mysql么?mysql不支持top,要用limit
      

  6.   

    是 MYSQL的~~~还是不行$result=mysql_query($sql,$link) or die("查询表失败".mysql_error());   //这行报错是不是 $link包含在 CONN.PHP里 需要设置成 全局变量?
      

  7.   

    sql="select * from news where class='.$class1.' limit 0,'.$num1.'";
    这个sql语句没错.
    如果这样还报错,检查你的表以及变量,给这个sql语句的变量赋具体值,然后直接在mysql执行。