<?php
/*
* @version V1.1 2002/July/12 (c) Erh-Wen,Kuo (erhwenkuo@yahoo.com). All rights reserved.
* Released under both BSD license and Lesser GPL library license.
* Whenever there is any discrepancy between the two licenses,
* the BSD license will take precedence.
*
* purpose: providing a example how to use "SqlAdmStart()" displaying well format html form
* with "Insert","Edit","Delete" link on the table.
*/
/* New class method:SqlAdmStart() is implemented at V1.1,2002/July/12 */
//Base on $action varaible to switch different process
switch($action){
case "delete":
//put your "delete" action code here
echo"Action is 'Delete'";
break;
case "insert":
//put your "insert" action code here
echo"Action is 'Insert'";
break;
case "edit":
//put your "edit" action code here
echo"Action is 'Edit'";
break;
default:
//include sql2table class
include_once('sql2table.class.php');
//setup parameters for initiating Sql2Table instance
//modify your mysql connection parameters & database name
$db_host="localhost";
$db_user="";
$db_pwd="";
$db_dbname="xcompany";
//create a new instance of Sql2Table class
$obj=new Sql2Table($db_host,$db_user,$db_pwd,$db_dbname);
//setup the page display limit
$limit=10;
//initiate $offset variable is necessary
if(!isset($offset)){
$offset=0;
}
/*Below is the key portion of this method,"SqlAdmStart()" would need at least 3 parameters
1.the script name,which would handle the action when user click the link
2.the keyfield of your table,for example "customer_id" in "customer" table.(should be unique)
3.qry string,which shows the records
This example script would handle all the action in the same script.But you could deside using
another script file to handle "Delete","Insert" or "Edit" action.
*/
$keyfield='customer_id';
$targettable='customer';
//the query string you want to show
//you could update below $query to suit your need
$query="Select * From $targettable";
//SqlAdmStart() is the main class method to do the trick
$obj->SqlAdmStart($PHP_SELF,$keyfield,$query,$offset,$limit);
//ShowTable() method would return a string combine Pages,Navigation&Sql Content
//in HTML table format. Easy for debugging!!
echo $obj->ShowTable();
}//switch($action) END
?> |