Simple Accounting

From FiFormsWiki

Jump to: navigation, search

This is a very simple tutorial for creating a program for tracking people's finances.

Creating Database and Tables

  • Create a database schema called tutorials
CREATE DATABASE `tutorials`;
  • Next create a table for people in your MySQL tutorials database.
CREATE TABLE `people` ( 
 `fName` VARCHAR( 20 ) NOT NULL ,
 `lName` VARCHAR( 25 ) NOT NULL ,
 `city` VARCHAR( 20 ) NOT NULL ,
 `state` VARCHAR( 2 ) NOT NULL ,
 `zip` INT NOT NULL ,
 `address1` VARCHAR( 40 ) NOT NULL ,
 `address2` VARCHAR( 40 ) NULL ,

Creating Main Form people.php

  • Now create a file in your web-server document root called 'people.php'.


To start off this little project we will type in an if statement that will redirect the user's web browser to the people.php file with the proper $_GET[] array data. 'sheetView=YES' shows the records in a table view, and 'firstVisit=NO' makes sure the redirection is only performed once.

if($_GET['firstVisit'] != 'NO')
header('Location: people.php?sheetView=YES&firstVisit=NO');
  • Now type these two lines in to include FiForms.
  • Now create a new object instance of the FiForms class called '$frm'.
$frm = new FiForm("People");
  • This line specifies what MySQL server to connect to.
$frm->dataServer = "localhost";
  • What table to connect to.
$frm->dataDB = "tutorials";
  • And what table within the database.
$frm->dataTable = "people";
  • Create a variable called $inputs that links to the same array as '$frm->inputs' using the ampersand operator.
$inputs = &$frm->inputs;
  • Now we are going to add objects to the $frm->inputs array using the addIn() FiForm member function. The inputs fields will be displayed in the order in which they are added. We first add the link to edit a record using the 'iLinkBack' object.
  • Add in an 'iText' object called 'pID' with a caption of 'ID' using the addIn function syntax: $frm->addIn('<Object Name>', '<database column>', '<caption>')
$frm->addIn('iText', 'pID', 'ID');
  • The pID field has a max length of 11 characters as determined with the 'create table' query we used to create the people table. So our pID field should only be 11 characters long in the FiForms form view. We change this by modifying the 'size' data-member of the 'pID' object.
$inputs['pID']->size = 11;
  • Now add the next 3 iText objects (form fields) and edit their size in the same way as shown above.
$frm->addIn('iText', 'fName', 'First Name');
      $inputs['fName']->size = 20;
$frm->addIn('iText', 'lName', 'Last Name');
      $inputs['lName']->size = 25;
$frm->addIn('iText', 'city', 'City');
      $inputs['city']->size = 20;


  • The iDBSelect object is used for drop-down form selections. We are going to use this type of object for selecting the state the person is from. It is added in the same way, and the size (width) of the text field is specified in the same way.
$frm->addIn('iDBSelect', 'state', 'State');
      $inputs['state']->size = 2;
  • But the drop-down menu contents are added by assigning an array to the rowQuery data-member. The array could also be the results of a query.
 $inputs['state']->rowQuery = array('AL', 'AK', 'AZ', 'AR', 'CA', 'CO', 'CT', 'DE', 'DC', 'FL',      
 'GA', 'HI', 'ID', 'KS', 'KY', 'LA', 'ME', 'MD', 'MA', 'MS', 'MO', 'MT', 'NE', 'NV', 'NJ', 'NM', 
 'NY', 'NC', 'ND', 'OH', 'OK', 'OR', 'PA', 'RI', 'SC', 'SD', 'TN', 'TX', 'UT', 'VT', 'VA', 'WA', 
 'WV', 'WI', 'WY');

Tutorial still needs to be completed. Check back later for updates

Personal tools
This is a cached copy of the requested page, and may not be up to date.

Sorry! This site is experiencing technical difficulties.
Try waiting a few minutes and reloading.

(Can't contact the database server: The server requested authentication method unknown to the client (localhost))

You can try searching via Google in the meantime.
Note that their indexes of our content may be out of date.