phpMyEdit Cheat Sheet
PHP Form Generator optionally places a "cheat sheet" of frequently used examples in the generated scripts.
$opts['filters'] = 'valid_user = "'.$valid_user.'" OR valid_user = "public"';
$opts['cgi']['persist'] = array('valid_user' => $valid_user );
Other filter examples:
$opts['filters'] = "column1 like '%11%' AND column2<17";
$opts['filters'] = "section_id = 9";
$opts['filters'] = "PMEtable0.sessions_count > 200"
Certain field options can be restricted to specific page modes (ACPVDFL). For example: 'help|ACP' or 'trimlen|LF'.
| 'php' |
If the 'php' option is set, a file of that name is included (and executed) in place of a value. Behavior is the same as in triggers. |
| 'colattrs' |
user-defined table cell attributes: 'colattrs|LF' => 'style="color:#ff0000;background-color:transparent"', |
| 'css' |
user-defined style class (e.g. '-right-justify' is applied to numeric columns by MFG) |
| 'datemask' |
applicable to TIMESTAMP(14) and DATETIME fields, e.g. 'Y-m-d H:i:s' |
| 'default' |
default values are extracted from MySQL |
| 'escape' |
set false to suppress htmlspecialchars() |
| 'help|ACP' |
help / guidance displayed in ACP modes in the last column |
| 'input' |
RWH (Readonly, passWord, Hidden) phpMyEdit version 5.4+ only |
| 'mask' |
a string (e.g. '%01.2f') used by sprintf() to format output |
| 'maxlen' |
maximum length to display add/edit/search INPUT boxes |
| 'name' |
title for column headings |
| 'nowrap' |
default is false (true/false re:NOWRAP) |
| 'options' |
ACPVDFL - optional parameter to control whether a field is displayed: A - add, C - change, P - copy, D - delete, V - view, F - filter, L - list
Alternative options: R - indicates that a field is read only W - indicates that a field is a password field H - indicates that a field is to be hidden and marked as hidden |
| 'required' |
true or false (true invokes javascript to prevent null entries) |
| 'select' |
select boxes: T - text, N - numeric, D - drop-down, M - multiple selection |
| 'size' |
size to display add/edit/search INPUT boxes (extracted from MySQL but set to 60 if > 60) |
| 'strftimemask' |
can be applied to INT fields containing a Unix timestamp 'strftimemask' => '%c', 'strftimemask' => '%a %m-%d-%Y %H:%M %p', |
| 'sort' |
true or false - sort the display on this column (clickable column header in List mode) |
| 'sql' |
provides access to MySQL functions (see documentation)
'sql|LFV' => 'if(start_date > "", CONCAT(start_date, "%b %e %Y - %a"), "")'
'sql|LFV' => 'if(FirstName <> "", CONCAT(LastName, ", ", FirstName), LastName)'
'sql' => 'CONCAT(FROM_UNIXTIME(col_name, "%a %b %e %Y %h:%i %p"))'
Transform an integer (Unix timestamp) to human readable date: 'sql|LFV' => 'if($col_name > "", CONCAT(DATE_FORMAT($col_name, "%a %b %e %Y %h:%i %p")), "")', |
| 'sqlw' |
'sqlw' => 'UPPER($val_as)' 'sqlw' => 'TRIM(UPPER($val_as))' 'sqlw' => 'IF($val_qas = "", NULL, $val_qas)' |
| 'strip_tags' |
true or false - whether to strip_tags() from displayed data |
| 'tab|ACP' |
see documentation |
| 'textarea' |
rows/cols - TEXTAREA attributes in ACP modes |
| 'trimlen' |
maximum length of string content to display (usually 'trimlen|LF') |
| 'URL' |
used to make a field 'clickable' in the display e.g.: 'mailto:$value', 'http://$value' or '$page?stuff'; |
| 'URLtarget' |
HTML target link specification, for example: _blank (see documentation) |
| 'values' |
$opts['fdd']['col_name']['values'] = array('0', '1', '2', '3'); |
| 'values2' |
$opts['fdd']['col_name']['values2'] = array('0' => 'No', '1' => 'Yes'); |
Extract 'values' from a different table (initialization):
$opts['fdd']['field_name'] = array(
'default' => '',
'maxlen' => 20,
'name' => 'Field Name',
'options' => 'ACPVDFL',
'required' => true,
'select' => 'T',
'size|ACP' => 20,
'sort' => true,
'values' => array(
'db' => 'dbname',
'table' => 'tblname',
'column' => 'col_name',
'description'=> array(
'columns' => array('0' => 'name', '1' => 'father_name', '2' => 'mother_name'),
'divs' => array('0' => ' - ', '1' => ' - '),
),
'filters' => 'col_name = "criteria"',
'orderby' => 'yet_another_col')
);
Extract 'values' from a different table (post-initialization may enhance readability):
$opts['fdd']['col_name']['values']['db'] = 'databaseName';
$opts['fdd']['col_name']['values']['table'] = 'extractTable';
$opts['fdd']['col_name']['values']['column'] = 'extractColumn';
$opts['fdd']['col_name']['values']['description']['divs']['-1'] = ', ';
$opts['fdd']['col_name']['values']['description']['columns']['0'] = 'desc_column_0';
$opts['fdd']['col_name']['values']['description']['divs']['0'] = ', ';
$opts['fdd']['col_name']['values']['description']['columns']['1'] = 'desc_column_1';
$opts['fdd']['col_name']['values']['filters'] = 'id = "something" ';
$opts['fdd']['col_name']['values']['orderby'] = 'another_column';
Dummy fields can be utilized with MySQL functions, or to display calculations:
$opts['fdd']['dummy1'] = array (
'name' => 'Dummy Field',
'sql' => 'CONCAT(first_name, " ", last_name)',
'options' => 'VDL',
'escape' => false,
'sort' => true
);
Javascript validation for entry of 0-9 in a numeric field:
$opts['fdd']['col_name']['js']['required'] = true;
$opts['fdd']['col_name']['js']['regexp'] = '/^[0-9]*$/';
$opts['fdd']['col_name']['js']['hint'] = 'Please enter only numbers in the "col_name" field.';
CGI variables:
$opts['cgi']['overwrite']['DateCreated'] = date('Y-m-d');
$opts['cgi']['persist'] = $some_variable;
$opts['cgi']['persist'] = array('article_id' => $article_id, 'session_id' => $session_id);
Notification examples:
$opts['notify']['from'] = '".$cfg_email_logging."';
$opts['notify']['prefix'] = $_SERVER['REQUEST_URI'].' - ';
$opts['notify']['wrap'] = '72';
$opts['notify']['insert'] = '".$cfg_email_logging."';
$opts['notify']['update'] = '".$cfg_email_logging."';
$opts['notify']['delete'] = '".$cfg_email_logging."';
$opts['notify']['all'] = '".$cfg_email_logging."'; // (insert, update, and, delete)
PHP Form Generator Home
| PHP Form Generator Demo
|