<?php
/**
* This is a basic example of using the Add-Modify-Delete class
*/
# default database configuration
$cfg_resource['default'] = array(
'server' => 'localhost',
'database' => 'tradeaxes',
'user' => 'tradeaxes',
'pass' => 'tradeaxes',
);
#main includes
require_once('class.Error.php');
require_once('class.Database.php');
require_once('class.Amd.php');
#create an Amd (Add-Modify-Delete) object
$amd = new Amd();
//add, Modify or Delete database records...
if($_POST){
//insert or update
$amd->set($_POST, 'users');
}elseif (isset($_GET['del'])){
//delete
$amd->delete($_GET, 'users');
}
//by default list users
$include = 'tpl.list_user.php';
if(isset($_GET['id']))
$include = 'tpl.set_user.php';
?>
<html>
<head>
<title>AMD example</title>
</head>
<body>
<?php
include($include);
echo '<br>',$amd->getErrors();
if($amd->sql != '')
echo '<br><b>AMD=</b> ',$amd->sql;
?>
</body>
</html>
|