Location: PHPKode > scripts > AJAX CRUD minimized > ajax-crud-minimized/example.php
<?php

	require_once('preheader.php');

	#the code for the class
	include ('ajaxCRUD.class.php');

    #this one line of code is how you implement the class
    ########################################################
    ##

    $tblDemo = new ajaxCRUD("Item", "tblDemo", "pkID");

    ##
    ########################################################

    ## all that follows is setup configuration for your fields....

    #define a relationship to another table
    #the first field is the fk in the table, the second is the second table, the third is the pk in the second table, and the forth is the field you want to retrieve as the dropdown value
    //$tblDemo->defineRelationship("fkOtherTableID", "tblOtherTable", "pkOtherTableID", "fldName");

    $tblDemo->omitPrimaryKey();

    $tblDemo->displayAs("fldField1", "Field1");
    $tblDemo->displayAs("fldField2", "Field2");
    $tblDemo->displayAs("fldCertainFields", "Certain Fields");
    $tblDemo->displayAs("fldLongField", "Long Field");

    $tblDemo->setTextareaHeight('fldLongField', 200);

    //$tblDemo->omitField("fldField2");
    //$tblDemo->omitAddField("fldField2");
    //$tblDemo->setFileUpload("fldFilename", "uploads/");
    //$tblDemo->disallowEdit('fldField2');
    //$tblDemo->addValueOnInsert("fldField2", "NOW()");

    //$tblDemo->addWhereClause("WHERE (fldField1 = 'test'");
    //$tblDemo->addOrderBy("ORDER BY fldField1 ASC");

    $allowableValues = array("Allowable Value 1", "Allowable Value2", "Dropdown Value", "CRUD");
    $tblDemo->defineAllowableValues("fldCertainFields", $allowableValues);

    //$tblDemo->disallowDelete();
    //$tblDemo->disallowAdd();
    //$tblDemo->addButtonToRow("Add", "add_item.php", "all");

    $tblDemo->setLimit(20); //number of rows display before showing paging

    //$tblDemo->turnOffAjaxEditing();
    $tblDemo->addAjaxFilterBox('fldField1');
    //$tblDemo->addAjaxFilterBox('fldField2');
    //$tblDemo->addAjaxFilterBoxAllFields();
    //$tblDemo->setAjaxFilterBoxSize('fldField1', 3);


    //$tblDemo->addTableBorder();
    //$tblDemo->addButton("Add Page", "page_management.php");

	#actually show to the table

	$tblDemo->formatFieldWithFunction('fldField1', 'makeBlue');
	$tblDemo->formatFieldWithFunction('fldField2', 'makeBold');

	#actually show the table
	$tblDemo->showTable();

	function makeBold($val){
		return "<b>$val</b>";
	}

	function makeBlue($val){
		return "$val";
	}

?>
Return current item: AJAX CRUD minimized