#use if you want to move the add form to the top of the page //$tblFriend->displayAddFormTop(); #order the table by any field you want $tblFriend->addOrderBy("ORDER BY fldName"); #add a button at the bottom of the table which simply goes to another page $tblFriend->addButton("No More Friends. Take Me Home", "./"); //$tblFriend->turnOffSorting(); //turns off ajax sorting by pressing header links //$tblFriend->disableTableHeaders(); //disables table headers from displaying //$tblFriend->turnOffAjaxEditing(); //turns of ajax editing of all data #some logic if we want to add a field automatically on add $state = ""; if (isset($_REQUEST['state'])) { $state = $_REQUEST['state']; } if ($state) { $tblFriend->addWhereClause("WHERE fldState = \"{$state}\""); $tblFriend->omitAddField("fldState"); $tblFriend->addValueOnInsert("fldState", $state); } echo "<h3>Example3 tests FormatFieldWithFunction, defineRelationship, Multiple Filters, and a Date Picker</h3>\n"; $tblFriend->showTable(); echo "<p>Above is a table of my friends. The javascript masking and validation are in the fields 'phone' and 'zip' (required). There's a datapicker on the 'Date we Met' field.</p>\n"; #self-defined functions used for formatFieldWithFunction function addDollarSign($val) { return "\$" . $val; } function displayImage($val) { return "<img src=\"uploads/{$val}\" width=\"90\">"; }
$tblEventAttendee->displayAs("fldLastName", "Last Name"); $tblEventAttendee->displayAs("fldPhone", "Phone #"); $tblEventAttendee->displayAs("fldWillBeLate", "Will You Be Late?"); $tblEventAttendee->displayAs("fldTimeArriving", "Arrival Time"); $tblEventAttendee->displayAs("fldComments", "Comments/Other"); $tblEventAttendee->displayAs("fldIPAddress", "IPAddress"); $tblEventAttendee->omitFieldCompletely("fldIPAddress"); $tblEventAttendee->omitFieldCompletely("fkEventID"); $tblEventAttendee->omitFieldCompletely("fldPhone"); $tblEventAttendee->omitFieldCompletely("fldAttending"); $tblEventAttendee->validateDeleteWithFunction("canRowBeModifiedOrDeleted"); $tblEventAttendee->validateUpdateWithFunction("canRowBeModifiedOrDeleted"); $tblEventAttendee->defineCheckbox("fldWillBeLate"); $tblEventAttendee->addOrderBy("ORDER BY fldFirstName ASC"); #Add WHERE clause so we only display information specific to the event that was selected $tblEventAttendee->addWhereClause("WHERE fkEventID = {$eventID}"); #I could add filter boxes to the top, but have chosen not to do so; commenting these out //$tblEventAttendee->addAjaxFilterBox("fldFirstName"); //$tblEventAttendee->addAjaxFilterBox("fldLastName"); //$tblEventAttendee->addAjaxFilterBox("fldAttending"); //using addValueOnInsert so when someone signs up it will automatically add them to this event $tblEventAttendee->addValueOnInsert("fkEventID", $eventID); //using addValueOnInsert to track their IP address $tblEventAttendee->addValueOnInsert("fldIPAddress", $_SERVER["REMOTE_ADDR"]); $tblEventAttendee->setTextboxWidth("fldTimeArriving", 8); $tblEventAttendee->setTextboxWidth("fldLastName", 25); $tblEventAttendee->setTextareaHeight("fldComments", 70); //comment field should be a bit wider height #set the number of rows to display (per page) $tblEventAttendee->setLimit(25); //after 25 people, the resultset will paginate
$limit = 10; break; } } else { $where = ""; $limit = 10; } } } $tbl = new ajaxCRUD("點位", "point", "id"); //$tbl->omitPrimaryKey(); $tbl->disallowEdit("id"); //$tbl->turnOffAjaxAdd(); // $tbl->turnOffAjaxEditing(); if (!empty($where)) { $tbl->addWhereClause($where); } $tbl->setLimit($limit); $tbl->omitField("owner"); $tbl->displayAs("name", "名稱"); $tbl->displayAs("alias", "別名"); $tbl->displayAs("type", "種類"); $tbl->formatFieldWithFunction('type', 'showIcon'); $tbl->displayAs("class", "等"); $tbl->displayAs("number", "號碼"); $tbl->displayAs("status", "狀態"); $tbl->displayAs("ele", "高度"); $tbl->displayAs("comment", "註解"); $tbl->displayAs("mt100", "百岳"); $tbl->displayAs("checked", "檢查"); $tbl->defineCheckbox('checked', '1', '0');
<?php require_once 'include/preheader.php'; // <-- this include file MUST go first before any HTML/output include 'include/ajaxCRUD.class.php'; // <-- this include file MUST go first before any HTML/output $tblDemo = new ajaxCRUD("Autos", "autos", "id_autos", ""); $tblDemo->defineRelationship("id_tipo", "tipo", "id_tipo", "desc_tipo"); $tblDemo->defineRelationship("id_modelo", "modelo", "id_modelo", "desc_modelo"); $tblDemo->defineRelationship("id_marca", "marca", "id_marca", "desc_marca"); $tblDemo->omitPrimaryKey(); $tblDemo->displayAs("nombre_autos", "Nombre"); $tblDemo->displayAs("desc_autos", "Descripcion"); $tblDemo->displayAs("detalle_autos", "Especificaciones"); $tblDemo->displayAs("precio_autos", "Precio"); $tblDemo->displayAs("id_marca", "Marca"); $tblDemo->displayAs("id_tipo", "Tipo"); $tblDemo->displayAs("id_modelo", "Modelo"); $tblDemo->setTextareaHeight('detalle_autos', 150); $tblDemo->addWhereClause("WHERE id_marca = 2 and id_tipo = 41"); $tblDemo->setLimit(30); $tblDemo->showTable();
$tblEvent->displayAs("fldAdditionalInformation", "Additional Information"); $tblEvent->displayAs("fldImage", "Image"); $tblEvent->displayAs("fldType", "Public/Private?"); $tblEvent->disallowDelete(); $validValues = array("Public", "Private"); $tblEvent->defineAllowableValues("fldType", $validValues); //$tblEvent->category_required['fldType'] = FALSE; $tblEvent->addOrderBy("ORDER BY fldDate ASC"); #Add filter boxes (if i wanted them) //$tblEvent->addAjaxFilterBox("fldFirstName"); //$tblEvent->addAjaxFilterBox("fldLastName"); //$tblEvent->addAjaxFilterBox("fldAttending"); $today = date("Y-m-d"); if (!$viewPastEvents) { #Add Where clause - only show future events $tblEvent->addWhereClause("WHERE (fldDate >= \"{$today}\") OR fldDate = \"0000-00-00\""); $signupText = "Sign up for Event"; $tblEvent->setFileUpload("fldImage", "uploads/", "uploads/"); } else { #Add Where clause - only show past events $tblEvent->addWhereClause("WHERE (fldDate < \"{$today}\") AND fldDate != \"0000-00-00\""); $signupText = "View Who Signed Up"; $tblEvent->turnOffAjaxEditing(); } $tblEvent->addButtonToRow($signupText, "index.php"); $tblEvent->setTextareaHeight("fldAdditionalInformation", 70); #set the number of rows to display (per page) //$tblEvent->setLimit(25); $tblEvent->setAddPlaceholderText("fldDate", "YYYY-mm-dd"); $tblEvent->setAddPlaceholderText("fldTime", "7:00pm"); $tblEvent->setAddFieldNote("fldDate", "Make sure to enter in format <b>YYYY-mm-dd</b>.");