Login   Register  
PHP Classes
elePHPant
Icontem

File: mysql_data_table_test.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Moellers Oma  >  MySQL_data_table  >  mysql_data_table_test.php  >  Download  
File: mysql_data_table_test.php
Role: Example script
Content type: text/plain
Description: Testscript
Class: MySQL_data_table
Generates html table from mysql data
Author: By
Last change:
Date: 11 years ago
Size: 2,955 bytes
 

Contents

Class file image Download
<?php
//Table config
$tbl_conf["align"] = "center";
$tbl_conf["width"] = "100%";
$tbl_conf["cellspacing"] = 0;
$tbl_conf["cellpadding"] = 2;
$tbl_conf["border"] = 1;

//th header config
$th_conf[0]["width"] = "50%";
$th_conf[1]["width"] = "30%";
$th_conf[2]["width"] = "20%";
$th_conf[3]["width"] = "20%";

//td data config
$td_conf[0]["align"] = "left";
$td_conf[1]["align"] = "center";
$td_conf[2]["align"] = "right";
$td_conf[3]["align"] = "right";

//headers
$headers[0]["order"] = "a";
$headers[1]["order"] = "b";
$headers[2]["order"] = "c";
$headers[3]["order"] = "d";
$headers[0]["show"] = "A";
$headers[1]["show"] = "B";
$headers[2]["show"] = "C";
$headers[3]["show"] = "D";

//Column config
$col_conf[0] = "link";
$col_conf[2] = "email";

//tr bgcolors
$colors[0] = "#999999";
$colors[1] = "#CCCCCC";

//Header pre- and suffix
$header_prefix '<h3>';
$header_suffix '</h3>';

//Data pre- and suffix
$data_prefix '<i>';
$data_suffix '</i>';

//Hide column 3
$hidden_column 3;

//Make it sortable
$sortable true;

//Sort it y and how
$sort_by "a";
$sort_mode "ASC";

//Max datasets shown each site
$max_data 50;

//Text for next and previous link
$next_text "N&auml;chste Seite&nbsp;&gt;&gt;";
$prev_text "&lt;&lt;&nbsp;Vorherige Seite";

//Show empty datasets
$show_empty false;

//show amount of pages
$show_page_count true;

//database settings
$query "SELECT a, b, c, d FROM table";
$db_host "localhost";
$db_user "user";
$db_pass "pass";
$db "database";

//assigning values and generating table
require_once("mysql_data_table.class.php");
$data_table = new mysql_data_table();
$data_table->set_query($query);
$data_table->execute_query($db_host$db_user$db_pass$db);
$data_table->set_tbl_config($tbl_conf);
$data_table->set_td_config($td_conf);
$data_table->set_th_config($th_conf);
$data_table->set_colors($colors);
$data_table->set_header($headers);
$data_table->set_header_prefix($header_prefix);
$data_table->set_header_suffix($header_suffix);
$data_table->set_data_prefix($data_prefix);
$data_table->set_data_suffix($data_suffix);
$data_table->set_col_config($col_conf);
$data_table->set_hidden_column($hidden_column);
$data_table->is_sortable($sortable);
$data_table->sort_data($sort_by$sort_mode);
$data_table->set_max_data($max_data);
$data_table->set_next_text($next_text);
$data_table->set_previous_text($prev_text);
$data_table->show_empty_data($show_empty);
$data_table->show_page_count($show_page_count);

$html $data_table->get_html();
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
    <title>Testpage for datatable of Sven Zurnieden</title>
</head>

<body>
<h1>Testpage for datatable of Sven Zurnieden</h1>
<br>
<br>
<?php echo $html?>
<br>
<br>
Written by <a href="mailto:sven.zurnieden@t-online.de">Sven Zurnieden</a>
</body>
</html>