PHP Example
Screen shot
index.php

<?php

// Mysql connectivity and database connnectivity
$conn=mysql_connect('localhost','root','') or die('Mysql Not connected');
$database=mysql_select_db('test',$conn) or die('Database Not connected');

// Getting starting position for mysql database record.
if(isset($_REQUEST['start']))
$start_no=$_REQUEST['start'];
else
$start_no=0;

// Total number of records par page
$page_size=8;

$i=0;
$page_no=1;

// Mysql query to fetch record from database
$query1="SELECT * FROM products limit $start_no,$page_size";
$result1=mysql_query($query1);

// Mysql query to count record from database
$query2="SELECT * FROM products";
$result2=mysql_query($query2);
$total_records=mysql_num_rows($result2);

?>
<html>
<head>
<title>PHP Pagination Example</title>
</head>
<body>
<table border='1'>
<tr>
<th>Sno</th>
<th>Record1</th>
<th>Record2</th>
</tr>
<?php
// To fetch record from database
while($row=mysql_fetch_array($result1))
{
$i++;
?>
<tr>
<td><?php echo $i; ?></td>
<td><?php echo $row[1]; ?></td>
<td><?php echo $row[5]; ?></td>
</tr>
<?php
}
?>
</table>
<table width="130" border='0'>
<tr>
<td width="42">
<a href='index.php?start=0'>First</a>
</td>
<?php
for($j=0;$j<$total_records;$j=$j+$page_size)
{
if($start_no==$j)
{
?>
<td width="29">
<span color='red' style='color:#FF0000'><?php echo $page_no; ?></span>
</td>
<?php
}
else
{
?>
<td width="29">
<a href='index.php?start=<?php echo $j; ?>'><?php echo $page_no; ?></a>
</td>
<?php
}
$page_no++;
}
?>
<td width="26">
<a href='index.php?start=<?php echo $j-$page_size; ?>'>Last</a>
</td>
</tr>
</table>
</body>
</html>

Database

--
-- Database: `test`
--

-- --------------------------------------------------------

--
-- Table structure for table `products`
--

CREATE TABLE IF NOT EXISTS `products` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `Code` varchar(20) NOT NULL,
  `Type` varchar(20) NOT NULL,
  `Name` varchar(30) NOT NULL,
  `Price` float(10,2) NOT NULL,
  `Image` varchar(50) NOT NULL,
  `Description` text NOT NULL,
  PRIMARY KEY (`ID`),
  UNIQUE KEY `Code` (`Code`),
  KEY `Type` (`Type`),
  KEY `Type_2` (`Type`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=40 ;

--
-- Dumping data for table `products`
--

INSERT INTO `products` (`ID`, `Code`, `Type`, `Name`, `Price`, `Image`, `Description`) VALUES
(1, '570D-E-F', 'Bracelets', 'BRL', 5800.00, 'BRA (1).jpg', ''),
(2, '571-A-B', 'Bracelets', 'BRL', 25000.00, 'BRA (2).jpg', ''),
(3, '570G-H', 'Bracelets', 'BRL', 6000.00, 'BRA (3).jpg', ''),
(4, '571E-F', 'Bracelets', 'BRL', 4500.00, 'BRA (4).jpg', ''),
(5, '571C-D', 'Bracelets', 'BRL', 22000.00, 'BRA (5).jpg', ''),
(6, '570G-H.', 'Bracelets', 'BRL', 5000.00, 'BRA (6).jpg', ''),
(7, '572D-E-F-G', 'Bracelets', 'BRL', 32000.00, 'BRA (7).jpg', ''),
(8, '573B-C', 'Bracelets', 'BRL', 6550.00, 'BRA (8).jpg', ''),
(9, '572-A-B-C', 'Bracelets', 'BRL', 7880.00, 'BRA (9).jpg', ''),
(10, '572H-I-J-K-L', 'Bracelets', 'BRL', 11425.00, 'BRA (10).jpg', ''),
(11, '638D-E', 'Earring', 'ER', 18800.00, 'ERN (1).jpg', ''),
(12, '638-A', 'Earring', 'ER', 35000.00, 'ERN (2).jpg', ''),
(13, '638B-C', 'Earring', 'ER', 25000.00, 'ERN (3).jpg', ''),
(14, '638F-G', 'Earring', 'ER', 3200.00, 'ERN (4).jpg', ''),
(15, '638H-I', 'Earring', 'ER', 0.00, 'ERN (5).jpg', ''),
(16, '638J-K', 'Earring', 'ER', 7600.00, 'ERN (6).jpg', ''),
(17, '639-A', 'Earring', 'ER', 86000.00, 'ERN (7).jpg', ''),
(18, '639B-C', 'Earring', 'ER', 65000.00, 'ERN (8).jpg', ''),
(19, '639D-E', 'Earring', 'ER', 4000.00, 'ERN (9).jpg', ''),
(20, '639F-G', 'Earring', 'ER', 0.00, 'ERN (10).jpg', ''),
(21, '639H-I', 'Earring', 'ER', 0.00, 'ERN (11).jpg', ''),
(22, '639J-K', 'Earring', 'ER', 5000.00, 'ERN (12).jpg', ''),
(23, '640B-C', 'Earring', 'ER', 0.00, 'ERN (13).jpg', ''),
(24, '640H-I', 'Earring', 'ER', 0.00, 'ERN (14).jpg', ''),
(25, '640-A', 'Earring', 'ER', 0.00, 'ERN (15).jpg', ''),
(26, '640F-G', 'Earring', 'ER', 0.00, 'ERN (16).jpg', ''),
(27, '640J-K', 'Earring', 'ER', 0.00, 'ERN (17).jpg', ''),
(28, '640D-E', 'Earring', 'ER', 0.00, 'ERN (18).jpg', ''),
(29, '641B-C', 'Earring', 'ER', 0.00, 'ERN (19).jpg', ''),
(30, '641-A', 'Earring', 'ER', 0.00, 'ERN (20).jpg', ''),
(31, '641D-E', 'Earring', 'ER', 0.00, 'ERN (21).jpg', ''),
(32, '641F-G', 'Earring', 'ER', 0.00, 'ERN (22).jpg', ''),
(33, '642B-C', 'Earring', 'ER', 0.00, 'ERN (23).jpg', ''),
(34, '641H-I', 'Earring', 'ER', 0.00, 'ERN (24).jpg', ''),
(35, '641J-K', 'Earring', 'ER', 0.00, 'ERN (25).jpg', ''),
(36, '642-A', 'Earring', 'ER', 0.00, 'ERN (26).jpg', ''),
(37, '642D-E', 'Earring', 'ER', 0.00, 'ERN (27).jpg', ''),
(38, '642F-G', 'Earring', 'ER', 0.00, 'ERN (28).jpg', ''),
(39, '643-A', 'Earring', 'ER', 0.00, 'ERN (29).jpg', '');

You can download source code here