<html> <head> <title>ThaiCreate.Com PHP & COM (ADO)</title> </head> <body> <?php $strConn = new COM("ADODB.Connection") or die("Cannot start ADO"); $strConn->Open("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" . realpath("mydatabase.mdb")); $strSQL = "SELECT * FROM customer "; $objRec = new COM("ADODB.Recordset"); $objRec->Open($strSQL, $strConn, 1,3); if($objRec->EOF) { echo "Not found Record."; } else { $PageLen = 2; $PageNo = $_GET["Page"]; if(!$PageNo) { $PageNo = 1; } $TotalRecord = $objRec->RecordCount(); $objRec->PageSize = $PageLen; $TotalPage = $objRec->PageCount(); $objRec->AbsolutePage = $PageNo; ?> <table width="600" border="1"> <tr> <th width="91"> <div align="center">CustomerID </div></th> <th width="98"> <div align="center">Name </div></th> <th width="198"> <div align="center">Email </div></th> <th width="97"> <div align="center">CountryCode </div></th> <th width="59"> <div align="center">Budget </div></th> <th width="71"> <div align="center">Used </div></th> </tr> <?php While (!($objRec->EOF) and $No < $PageLen) { ?> <tr> <td><div align="center"><?php echo $objRec->Fields["CustomerID"]->Value;?></div></td> <td><?php echo $objRec->Fields["Name"]->Value;?></td> <td><?php echo $objRec->Fields["Email"]->Value;?></td> <td><div align="center"><?php echo $objRec->Fields["CountryCode"]->Value;?></div></td> <td align="right"><?php echo $objRec->Fields["Budget"]->Value;?></td> <td align="right"><?php echo $objRec->Fields["Used"]->Value;?></td> </tr> <?php $No = $No + 1; $objRec->MoveNext(); } ?> </table> <?php } $objRec->Close(); $strConn->Close(); $strConn = null; ?> Total : <?php echo $TotalRecord?> Page <?php echo $PageNo?> All Page <?php echo $TotalPage?> <?php if($PageNo > 1){ ?> <a href="<?php echo $_SERVER[SCRIPT_NAME];?>?Page=1"><< First</a> <a href="<?php echo $_SERVER[SCRIPT_NAME];?>?Page=<?php echo $PageNo-1?>">< Back</a> <?php }?> <?php if($PageNo < $TotalPage) { ?> <a href="<?php echo $_SERVER[SCRIPT_NAME];?>?Page=<?php echo $PageNo+1?>">Next ></a> <a href="<?php echo $_SERVER[SCRIPT_NAME];?>?Page=<?php echo $TotalPage?>">Last >></a> <?php }?> <br> Go to <?php for($intID=1;$intID<=$TotalPage;$intID++){?> <?php if($intID == $PageNo){?> <b><?php echo $intID?></b> <?php }else{?> <a href="<?php echo $_SERVER[SCRIPT_NAME];?>?Page=<?php echo $intID?>"><?php echo $intID?></a> <?php }?> <?php }?> </body> </html>
ช่วยกันสนับสนุนรักษาเว็บไซต์ความรู้แห่งนี้ไว้ด้วยการสนับสนุน Source Code 2.0 ของทีมงานไทยครีเอท