限制将在表格上显示的数据并为下一个数据添加页面。像gridview一样的表

时间:2013-04-08 06:48:06

标签: php html

我有我的sql server连接

$sql_exp = "select * from dbo.PC inner join dbo.FA_PC on dbo.PC.PCID = dbo.FA_PC.PCID WHERE UserID is NOT NULL order by dbo.fa_pc.PCID"; 
   $sql_exp1= "select * from dbo.users inner join dbo.FA_PC on dbo.users.UserID = dbo.FA_PC.UserID order by dbo.fa_pc.PCID";
    $sql_exp2 = "select * from dbo.FA_Type inner join dbo.FA_PC on dbo.FA_Type.FA_TypeID = dbo.FA_PC.FA_TypeID order by dbo.fa_pc.PCID"; 
   $rs = $conn->Execute($sql_exp);
    $rs1 = $conn->Execute($sql_exp1);
  $rs2 = $conn->Execute($sql_exp2);
   echo "<table border='1' cellpadding='1' cellspacing='0' id='rounded-corner'><tr><th>Desktop Number</th><th>Employee</th><th><p align=left>Fixed Asset Accountability</p></th></tr>";
   echo '<select name="print">'; 
   echo "<option value=".$rs->Fields("PC_Number")."> </option>";
   while (!$rs->EOF) {
       set_time_limit(0);


       echo "<td>CP # <br>".$rs->Fields("PC_Number")."</td>";   
       echo "<td>".$rs1->Fields("EmployeeName")."</td>";    
      echo "<td>".$rs2->Fields("FA_Type")."</td><tr>";  

      $rs->MoveNext();
      $rs1->MoveNext();
      $rs2->MoveNext();
   }
   echo "</table>";   
   $rs->Close();
   $rs1->Close();
   $rs2->Close();  

所以这段代码只打印我数据库中的每一个数据,大约100个细节,我怎样才能将数据输入限制在10,20,30,40,50,100之间,只需添加几个下一页和上一页的链接数据很可能是网格视图形式

1 个答案:

答案 0 :(得分:0)

尝试放置LIMIT。例如,对于第1页LIMIT 0, 10,第2页LIMIT 10,10,第3页,“限制20,10”,依此类推......

其中LIMIT 0(page), 10(max content shows)