PHP Mysql Example: Display Table As HTML: 'Localhost' 'Root' 'Lptm42B' 'Sphinx' 'Spheres'
PHP Mysql Example: Display Table As HTML: 'Localhost' 'Root' 'Lptm42B' 'Sphinx' 'Spheres'
HTML
abstract
This example use MySQL functions from PHP to display full MySQL table(every column and
every row) as HTML.
compatible
PHP 3, 4
PHP 5
We use following MySQL functions in this example:
You can get help on this functions typing "php function-name" in any good search engine
Before using following sample, change varibales ($db_host, $db_user, $db_pwd, $database,
$table) to your MySQL / database settings
source code: php
<html><head><title>MySQL Table Viewer</title></head><body>
<?php
$db_host = 'localhost';
$db_user = 'root';
$db_pwd = 'lptm42b';
$database = 'sphinx';
$table = 'spheres';
if (!mysql_connect($db_host, $db_user, $db_pwd))
die("Can't connect to database");
if (!mysql_select_db($database))
die("Can't select database");
// sending query
warning
This example may work wrong with some strange column data (for example, binary BLOB).
It show column data as it receives it from MySQL
tested
FreeBSD 5.2 :: PHP 5.1.4
Linux CentOS 4.0 :: PHP 5.1.5