如何删除分页中的查询错误



我有一个从php页面调用的函数,但是当我调用函数时,它给出了一个错误,这是我的代码:

function getbussinesspagination($profit_id,$start,$per_page)
{
    $select = "select a.title,a.credit,
                 (select name from main102.Location_4 where id=a.location_4) as cityName,
                 (select a.account_id from listing,article r 
                      where a.account_id=r.account_id 
                      group by a.account_id) as article,
                 (select a.account_id from listing,event e where a.account_id=e.account_id 
                      group by a.account_id) as event,
                 a.renewal_date, l.name 
               from listing a,
               listinglevel l LIMIT 
               where l.value=a.level and 
                 a.profit_instructor_id='".$profit_id."' 
                group by a.account_id '".$start."','".$per_page."'";
    $res = $GLOBALS ['mysqli']->query ($select) or die ($GLOBALS ['mysqli']->error . __LINE__);
    if ($res->num_rows > 0)
    {
        return $res;
    }
    else
    {
        return false;
    }
}
if($_POST['page'])
{
    $page = $_POST['page'];
    $cur_page = $page;
    $page -= 1;
    $per_page = 10;
    $start = $page * $per_page;
    include_once ("config.php"); 
    include_once ("function.php");
    $business = getbussinesspagination(0,$start,$per_page);
?>

当我执行页面时,它给出错误

You have an error in your SQL syntax; check the manual that corresponds to your 
MySQL server version for the right syntax to use near 
  'where l.value=a.level and a.profit_instructor_id='0' group by a.account_id '10',' 
  at line 221

你在 LIMIT 附近有 sql 语法错误,请更正它:

$select="select a.title,a.credit,
            (select name from main102.Location_4 where id=a.location_4) as cityName,
            (select a.account_id 
               from listing, article r 
               where a.account_id=r.account_id 
               group by a.account_id) as article,
            (select a.account_id from listing,event e 
              where a.account_id=e.account_id 
              group by a.account_id) as event,
         a.renewal_date, l.name 
         from listing a,listinglevel l  
         where l.value=a.level and a.profit_instructor_id='".$profit_id."' 
         group by a.account_id 
         LIMIT ".$start.", ".$per_page

最新更新