n. 1. the inherit form in every MySQL table. 2. the php script that makes it happen.

Support This Project

Integrating with Smarty or Other Templating System

















Code

<?PHP

include("Formitable.class.php");
$newForm = new Formitable( mysql_connect("server","user","pass"),"db","table" );
$newForm->hideField("ID");

//set all output to be returned instead of printed
$newForm->returnOutput = true;
$formOutput = $newForm->printForm();

//smarty
@require("smarty/Smarty.class.php");
$smarty = new Smarty;
$smarty->template_dir = 'smarty/template';
$smarty->compile_dir = 'smarty/compile';
$smarty->cache_dir = 'smarty/cache';
$smarty->config_dir = 'smarty/config';
$smarty->assign('formitable',$formOutput);
$smarty->display("smarty.tpl");
?>

Template

<center><div class="boxed">
{$formitable}
</div></center>

MySQL Table

CREATE TABLE formitable_simple (
  ID tinyint(3) unsigned NOT NULL auto_increment,
  first_name varchar(25) NOT NULL default '',
  last_name varchar(25) NOT NULL default '',
  about_yourself tinytext NOT NULL,
  date_of_birth date NOT NULL default '0000-00-00',
  `what_day_is_it?` enum('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday') NOT NULL default 'Monday',
  PRIMARY KEY  (ID)
) TYPE=MyISAM