PHP Classes

File: mysql_data_table_test.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in Bookmark in
  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: 12 years ago
Size: 2,955 bytes


Class file image Download
//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[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
$data_table = new mysql_data_table();
$data_table->execute_query($db_host, $db_user, $db_pass, $db);
$data_table->sort_data($sort_by, $sort_mode);

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

<h1>Testpage for datatable of Sven Zurnieden</h1>
<?php echo $html?>
Written by <a href="">Sven Zurnieden</a>