PHP Classes

File: Example.php

Recommend this page to a friend!
  Classes of SanvidPatel  >  SPaging  >  Example.php  >  Download  
File: Example.php
Role: Example script
Content type: text/plain
Description: Example
Class: SPaging
This class can be used to display MySQL database q
Author: By
Last change:
Date: 13 years ago
Size: 1,169 bytes
 

Contents

Class file image Download
<?
    $dbhost
= 'localhost';
   
$dbuser = 'root';
   
$dbpass = '';
   
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');

   
$dbname = 'databasename';
   
mysql_select_db($dbname);
    include(
"Paging.php");
?>
<html>
<head>
<title>Test Paging</title>
<link href="stylesheet.css" rel="stylesheet" type="text/css">
</head>
<body>

<?
   
// This code must be put before the form tag
   
   
$Obj=new Paging("select * from tablename");
   
$Obj->setLimit(5);//set record limit per page
   
$limit=$Obj->getLimit();
   
$offset=$Obj->getOffset($_REQUEST["page"]);
   
//below is optional parameter
   
$Obj->setParameter("&name=Test&address=India");
   
//set link css
   
$Obj->setStyle("redheading");
   
$Obj->setActiveStyle("smallheading");
   
$Obj->setButtonStyle("boldcolor");
//End Here

?>
<form >
<table border="1">
  <?
    $sql
="select * from tablename limit $offset,$limit";
   
$rs=mysql_query($sql);
    while(
$row=mysql_fetch_array($rs)) {
?>
<tr>
    <td><?=$row[fieldname]?></td>
  </tr>
  <?
   
}
?>
</table>
</form>
<?
   
// This code Must be put After the Form tag
    //get page links
   
$Obj->getPageNo();
?>
</body>
</html>

For more information send a message to info at phpclasses dot org.