2013-11-27 79 views
-1

我不知道我試圖連接數據庫與我的面板,但它給出了一些錯誤任何幫助將不勝感激.................. .................................................. ...............................................PHP的管理面板分頁

<?php 
if (!(isset($pagenum))) 
      { 
      $pagenum = 1; 
      } 
      $qry = "SELECT * FROM posts LIMIT 0,3"; 
      $result = mysqli_query($qry,$con); 
      $rows = mysqli_num_rows($qry); 
      $page_rows = 3; 
      $last = ceil($rows/$page_rows); 

      if ($pagenum < 1) 
      { 
      $pagenum = 1; 
      } 
      elseif ($pagenum > $last) 
      { 
      $pagenum = $last; 
      } 
          $max = 'limit ' .($pagenum - 1) * $page_rows .',' .$page_rows; 


     $j=0; 
     $qry ="SELECT * FROM posts $max"; 
     $result = mysqli_query($con,$qry); 
      //This is where you display your query results 
      while($rows = mysqli_fetch_array($result)) 
      { 
      $j++; 

     echo "<p>"; 
      // This shows the user what page they are on, and the total number Query and Results of pages 
      echo " --Page $pagenum of $last-- 
      <p>"; 
      // First we check if we are on page one. If we are then we don't need a 
      //link to the previous page or the first page so we do nothing. If we aren't 
      //then we generate links to the first page, and to the previous page. 

      if ($pagenum == 1) 
      { 
      } 
      else 
      { 
      echo " <a 
      href='{$_SERVER['PHP_SELF']}?pagenum=1'> 
      <<-First</a> 
      "; 
      echo " "; 
      $previous = $pagenum-1; 
      echo " <a 
      href='{$_SERVER['PHP_SELF']}? 
      pagenum=$previous'> <-Previous</a> 
      "; 
      } 
      //just a spacer 
      echo " ---- "; 
      //This does the same as above, only checking if we are on the last page, 
      //and then generating the Next and Last links 
      if ($pagenum == $last) 
      { 
      } 
      else { 
      $next = $pagenum+1; 
      echo " <a 
      href='{$_SERVER['PHP_SELF']}?pagenum=$next'>Next 
      -></a> "; 
      echo " "; 
      echo " <a 
      href='{$_SERVER['PHP_SELF']}?pagenum=$last'>Last 
      ->></a> "; 
      } 
          ?> 
+0

請添加代碼 –

回答

0
echo $_SESSION['username']; 

如果您在成功登錄時將$ _POST用戶名保存在會話中,會做伎倆。我們理想的是真的需要看到你正在使用的PHP代碼,但這是如何完成你的後續工作的基本想法

+0

假設該值存儲在'$ _SESSION'中。 – BenM

+0

thx和等等leme試試:) –

+0

是的,我發現它後,我意識到這一點。這取決於你如何設置你的代碼 –