1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
| <?php
session_start();
ob_start();
extract($_REQUEST);
//Connect to db
mysql_select_db($db_name,mysql_connect($hostname,$username,$passwd));
//get table column data
$sqlc = "show columns from $table_name";
$rsdc = mysql_query($sqlc);
$cols = mysql_num_rows($rsdc);
//get table contents
$start = ($page-1)*10;
$sql = "select * from $table_name order by $order_by limit $start,$per_page";
$rsd = mysql_query($sql);
?>
<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<title>Result</title>
</head>
<body>
<div align="center" id="content">
<table border="0" cellpadding="2" cellspacing="2" width="100%" id="table1">
<tr>
<td>Sl. No</td>
<?php
//Print the column headings
while($rsc = mysql_fetch_array($rsdc))
{
?>
<td><?=$rsc[0]?></td>
<?php
}
?>
</tr>
<?php
//Print the contents
$i = $start;
while($rs = mysql_fetch_array($rsd))
{
$i++;
?>
<tr>
<td><?=$i?> </td>
<?php
for($j=0; $j<$cols; $j++)
{
?>
<td><?=$rs[$j]?></td>
<?php
} //for
?>
</tr>
<?php
} //while
?>
</table>
</div>
</body>
</html> |
Partager