Best Web Host

phpMyEdit example

MySQL™ table editor

Filename: phpvs_sakila.city.php

Page: 1 of 61  Records: 601
City ID City Country ID Last Update
Clear Sorted By: City ID ascending
View Change Copy Delete 1 A Corua (La Corua) 87 2006-02-15 04:45:25
View Change Copy Delete 2 Abha 82 2006-02-15 04:45:25
View Change Copy Delete 3 Abu Dhabi 101 2006-02-15 04:45:25
View Change Copy Delete 4 Acua 60 2006-02-15 04:45:25
View Change Copy Delete 5 Adana 97 2006-02-15 04:45:25
View Change Copy Delete 6 Addis Abeba 31 2006-02-15 04:45:25
View Change Copy Delete 7 Aden 107 2006-02-15 04:45:25
View Change Copy Delete 8 Adoni 44 2006-02-15 04:45:25
View Change Copy Delete 9 Ahmadnagar 44 2006-02-15 04:45:25
View Change Copy Delete 10 Akishima 50 2006-02-15 04:45:25
Page: 1 of 61  Records: 601

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: city
 * Row count: 601
 * Column count: 4
 * Filename: phpvs_sakila.city.php
 * Created Wed, 22 Feb 2012 08:41:49 -0700
 * Primary key: city_id
 * Multi-key fields: country_id
 * All fields: city_id, city, country_id, last_update
*/

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

// 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('city_id');

$opts['key'] = 'city_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 4 columns


// Begin phpMyEdit field arrays

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


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


// column 2: `country_id` int - smallint(5) unsigned
// flags: multiple_key, not_null, unsigned
$opts['fdd']['country_id'] = array(
  
'css'        => array('postfix' => 'right-justify'),
  
'default'    => '',
  
'help|ACP'   => 'Limit 5 digits',
  
'input'      => '',
  
'maxlen'     => 5,
  
'name'       => 'Country ID',
  
'options'    => 'ACPVDFL',
  
'select'     => 'T',
  
'size'       => 5,
  
'sqlw'       => 'TRIM("$val_as")',
  
'sort'       => true
);
$opts['fdd']['country_id']['js']['required'] = true;
$opts['fdd']['country_id']['js']['regexp'] = '/^[0-9]*$/';
$opts['fdd']['country_id']['js']['hint'] = 'An entry is required for Country ID';


// column 3: `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.