All pastes #203060 Raw Edit

A-L-P-H-A

public text v1 · immutable
#203060 ·published 2006-10-14 22:21 UTC
rendered paste body
<?php
// Connection setup.
require_once 'DBConnect.php'

// basic classes
require_once 'MDB2.php';

require_once 'DB/Table.php';


class InvoiceUsers extends DB_Table {

	var $col = array(

		'id' 			=> array('type'    => 'integer',	'require' => true, 	'qf_type'=>'hidden'),

		'name' 		=> array('type'    => 'varchar',	'size'    => 32, 		'qf_label'=> 'Name (e.g. "John Smith")', 'qf_attrs'=> array('style'=>'background:#f00;')),

		'address'	=> array('type'    => 'clob',		'qf_type'=> 'textarea'),

		'phone' 		=> array('type'    => 'varchar',	'size'    => 32, 'qf_type'=>'text', 'qf_label'=> 'Phone number') ,

		'email'		=> array('type'    => 'varchar',	'size'    => 128,		'require' => true ,'qf_type'=>'text'),

		'signdate' 	=> array('type'    => 'date',		'qf_type'=>'date',	'require' => true)
	);



	var $idx = array(

			'id' => 'unique'

	);


};


$tablename = "testme";

$auto_create = 'safe';

$book =& new InvoiceUsers($mdb2, $tablename, $auto_create);



if ($book->error) {

    echo "Failure!  Try again.";

    print_r($book->error);

	die;

}

// setup what to display.
$cols = array(
	'name' => '',
	'address' => '',
	'phone' => '',
	'email' => '',
	'date' => date('Y-m-d') // trying to figure out how to have today's date as the default data
);

$form =& $book->getForm($cols);

// add a "submit" button named "op" that says "Go!"
$form->addElement('submit', 'op', 'Save');

// add a reset button
$form->addElement('reset', '', 'Reset');

$form->display();

?>