使用pdo时,分页代码中存在一些错误

时间:2017-11-16 10:21:03

标签: php mysql pdo

这是我使用PDO进行分页时的代码,那么这个代码之后不要运行任何代码,这个代码有什么问题我不知道,在这段代码之后一切正常,所以求助我请,这是代码

if ($search)
              {
                        $all_stmt=$db->prepare("select COUNT(*) from files where recieved_by like :needle or processed_by like  :needle or   purpose like :needle or file_name like  :needle order by date desc");
                        $needle = '%" . $search . "%';
                        $all_stmt->bindValue(':needle', $needle, PDO::PARAM_STR);  
                        $all_stmt->execute();
                        $all_post=$all_stmt->fetchColumn();
                        $total_page = ceil($all_post / $total_num_page);
                        $page_start_from = ($page_id - 1) * $total_num_page;
              } 
               else 
               {
                    $all_stmt=$db->prepare( "select COUNT(*) from files order by date desc");
                    $all_stmt->execute();
                    $all_post=$all_stmt->fetchColumn();
                    $total_page = ceil($all_post / $total_num_page);
                    $page_start_from = ($page_id - 1) * $total_num_page;
               } 

这段代码有什么问题?

0 个答案:

没有答案