<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
body { font-size:13px; font-family:"Myriad Pro",Arial,Helvetica,sans-serif; }
#table-id { border-collapse:collapse; border-color:#fff; font-size:12px; font-family:Tahoma, Geneva, sans-serif; }
#table-id thead th { background-color:#C3D5DA; color:#333; height:30px; }
#table-id tbody td { text-align:center; height:25px; padding-left:10px; padding-right:10px; }
#table-id tbody td span.no { text-align:center; color:red; }
#table-id tbody td span.category { text-align:left; color:#444; }
#table-id tbody td span.sname { color:#444; }
#table-id tbody tr:hover { background-color:#FFEACD;}
.txt-err { color:red; }
.odd { background-color:#F1F3F4; }
.even { background-color:#E2EAEC; }
</style>
</head>
<body>
<?php
require_once ('start_connect.inc.php');
require_once ('class_table.php');
/**
* config table attribute
* config table header
* config table row css class
*/
$attr = 'id="table-id" border="1"';
$head = array(' ID. ', ' Name ', ' Surname ', ' Email ');
$rcss = array('class="odd"', 'class="even"');
/**
* get result from database
* fetch result store to array data
*/
$result = mysql_query("SELECT * FROM test_table ORDER BY id ASC") or die (mysql_error());
if($result) {
while($rs = mysql_fetch_assoc($result)) {
$data[] = array(
'<span>'.$rs['id'].'</span>',
'<span>'.$rs['name'].'</span>',
'<span>'.$rs['surname'].'</span>',
'<span>'.$rs['email'].'</span>'
);
}
}
/**
* create table instance
*/
$table = new Table($attr, $head, $data, $rcss);
/**
* display table
*/
try {
$table ->createTable();
}
catch(Exception $e) { echo $e->getMessage(); }
?>
</body>
</html>
|