Best Web Host

phpMyEdit example

MySQL™ table editor

Filename: phpvs_sakila.category.php

Page: 1 of 2  Records: 18
Category ID Name Last Update
Clear Sorted By: Category ID ascending
View Change Copy Delete 2 Animation 2006-02-15 04:46:27
View Change Copy Delete 3 Children 2006-02-15 04:46:27
View Change Copy Delete 4 Classics 2006-02-15 04:46:27
View Change Copy Delete 5 Comedy 2006-02-15 04:46:27
View Change Copy Delete 6 Documentary 2006-02-15 04:46:27
View Change Copy Delete 7 Drama 2006-02-15 04:46:27
View Change Copy Delete 8 Family 2006-02-15 04:46:27
View Change Copy Delete 9 Foreign 2006-02-15 04:46:27
View Change Copy Delete 10 Games 2006-02-15 04:46:27
View Change Copy Delete 11 Horror 2006-02-15 04:46:27
Page: 1 of 2  Records: 18

Tables containing more than 'n' columns are configured to display the first 'n' columns and display links to toggle (add/remove) the remaining columns.

Users are advised to use phpMyAdmin to set an INDEX for columns which are often sorted/searched. Most web hosts provide phpMyAdmin in the website control panel.

Try Hostgator.com for excellent web hosting with cPanel, PHP, MySQL™ and many other features. cPanel PHP MySQL web hosting


phpMyEdit code created for the above table.

<?php

/*
 * Database: phpvs_sakila
 * Table: category
 * Row count: 18
 * Column count: 3
 * Filename: phpvs_sakila.category.php
 * Created Tue, 21 Feb 2012 04:38:04 -0700
 * Primary key: category_id
 * All fields: category_id, name, last_update
*/

$opts['tb'] = 'category';

// phpMyEdit common variables + a few functions + UTF8 database connection

require_once('./resources/inc/config.php');

require_once(
'./resources/inc/header.php');

// Use phpMyAdmin to apply an INDEX to columns which are frequently sorted/searched.
// Prepending a minus sign (-) to a sort_field value causes DESCending sort order.

$opts['sort_field'] = array('category_id');

$opts['key'] = 'category_id';

$opts['key_type'] = 'int';

$opts['options'] = 'ACPVDFL';

// $opts['triggers']['insert']['after'] = 'resources/inc/triggers/view_rec_after_add.php';

if(empty($list_mode_status)){
   
// List mode
}elseif(isset($_REQUEST['PME_sys_operation']) || isset($_REQUEST['PME_sys_moreadd']) && isset($_REQUEST['PME_sys_morechange'])){
   
// 7 diffenent button clicks may occur
   // PME_sys_operation: Add, PME_op_Change, PME_op_Copy, PME_op_Delete, PME_op_View
   // PME_sys_moreadd: More
   // PME_sys_morechange: Apply
}

// Toggle preference disabled given only 3 columns


// Begin phpMyEdit field arrays

// column 0: `category_id` int - tinyint(3) unsigned
// flags: auto_increment, not_null, primary_key, unsigned
// extra: auto_increment
$opts['fdd']['category_id'] = array(
  
'css'        => array('postfix' => 'right-justify'),
  
'default'    => '',
  
'input'      => 'R',
  
'name'       => 'Category ID',
  
'options'    => 'VCDFL',
  
'select'     => 'T',
  
'size'       => 3,
  
'sort'       => true
);
// If the tab feature is implemented, the first column must have a tab
// $opts['fdd']['category_id']['tab|ACP'] = 'Category ID';


// column 1: `name` string - varchar(25)
// flags: not_null
// collation: utf8_general_ci
$opts['fdd']['name'] = array(
  
'default'    => '',
  
'help|ACP'   => 'Limit 25 characters',
  
'input'      => '',
  
'maxlen'     => 25,
  
'name'       => 'Name',
  
'options'    => 'ACPVDFL',
  
'select'     => 'T',
  
'size'       => 25,
  
'sqlw'       => 'TRIM("$val_as")',
  
'sort'       => true
);
$opts['fdd']['name']['js']['required'] = true;
$opts['fdd']['name']['js']['hint'] = 'An entry is required for Name';


// column 2: `last_update` timestamp
// flags: binary, not_null, timestamp, unsigned, zerofill
// extra: on update CURRENT_TIMESTAMP
$opts['fdd']['last_update'] = array(
  
'css'        => array('postfix' => 'right-justify'),
  
'default'    => '',
  
'help|ACP'   => 'Timestamp',
  
'input'      => 'R',
  
'maxlen'     => 19,
  
'name'       => 'Last Update',
  
'options'    => 'VDFL',
  
'select'     => 'N',
  
'size'       => 19,
  
'sqlw'       => 'TRIM("$val_as")',
  
'sort'       => true
);
$opts['fdd']['last_update']['js']['required'] = true;
$opts['fdd']['last_update']['js']['hint'] = 'An entry is required for Last Update';

require_once(
'./resources/inc/phpMyEdit.class.new.php');

new 
phpMyEdit($opts);

require_once(
'./resources/inc/footer.php');

?>


cPanel PHP MySQL web hosting

If you have pre-purchase questions, please call Doug Hockinson at (720) 334-7850 or send email to doug@hockinson.com.

Data used for this demo is a modified version of Sakila schema (converted to MyISAM type tables)

Related sites: php-form-generator.com | phpvs.com | hockinson.com | denvermetro.org

Content management system with built in photo galleries and phpMyEdit form generator: www.phpvs.com/cms2011/

Regarding the style sheet used by these scripts, un-comment some CSS code for body and wrapper in order to match the layout of the generator script.

In page modes Add, Change, and coPy, note the Help text displayed beside the fields. Several configurable options are available: character limit, link to Help popup, code supplied but commented out (no value), display "Entry Required", or MySQL Column Comment.