dsu5188 2018-01-29 13:30
浏览 50

使用mySQL查询在PHP中的在线目录中进行页面编号

I am trying to fix this query where the first entry to the table is given a page number of 12 (the first 10 pages is the cover and adverts). Once the first page has been entered, then the pages increase by 2 every time. The original query was:

$get_max_page=mysql_query("SELECT MAX(page_no) as Page FROM `lots`");
if(mysql_num_rows($get_max_page)>0)
{
    $page_row=mysql_fetch_array($get_max_page);
    $page_no=$page_row['Page']+2;
}else{
    $page_no=12;
}

After considerable reviewing and changing, my latest version is, but still not working, is:

$get_max_page=mysql_query("SELECT MAX(page_no) AS get_max_page FROM lots");
if(mysql_fetch_array($get_max_page)!=NULL)
{
    $page_row=mysql_fetch_array($get_max_page);
    $page_no=$page_row['Page']+2;
}else{
    $page_no=12;
}

Can anyone give suggestion on how this could work please as the first entry continually gives a page number of 2.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
    • ¥20 西门子S7-Graph,S7-300,梯形图
    • ¥50 用易语言http 访问不了网页
    • ¥50 safari浏览器fetch提交数据后数据丢失问题
    • ¥15 matlab不知道怎么改,求解答!!
    • ¥15 永磁直线电机的电流环pi调不出来
    • ¥15 用stata实现聚类的代码
    • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
    • ¥20 docker里部署springboot项目,访问不到扬声器
    • ¥15 netty整合springboot之后自动重连失效