Best Web Host

phpMyEdit example

MySQL™ table editor

Filename: phpvs_sakila.film.php


Additional Fields
 Original Language ID
 Rental Duration
 Rental Rate
 Length
 Replacement Cost
 Rating
 Special Features
 Last Update


 
Page: 1 of 100  Records: 998
Film ID Title Description Release Year Language ID
Clear Sorted By: Film ID ascending
View Change Copy Delete 2 ACE GOLDFINGER A Astounding Epistle of a Database Administrato... 2006 1
View Change Copy Delete 3 ADAPTATION HOLES An Astounding Reflection of a Lumberjack And a ... 2006 1
View Change Copy Delete 4 AFFAIR PREJUDICE A Fanciful Documentary of a Frisbee And a Lumbe... 2006 1
View Change Copy Delete 5 AFRICAN EGG A Fast-Paced Documentary of a Pastry Chef And a... 2006 1
View Change Copy Delete 6 AGENT TRUMAN A Intrepid Panorama of a Robot And a Boy who mu... 2006 1
View Change Copy Delete 7 AIRPLANE SIERRA A Touching Saga of a Hunter And a Butler who mu... 2006 1
View Change Copy Delete 8 AIRPORT POLLOCK A Epic Tale of a Moose And a Girl who must Conf... 2006 1
View Change Copy Delete 9 ALABAMA DEVIL A Thoughtful Panorama of a Database Administrat... 2006 1
View Change Copy Delete 10 ALADDIN CALENDAR A Action-Packed Tale of a Man And a Lumberjack ... 2006 1
View Change Copy Delete 12 ALASKA PHANTOM A Fanciful Saga of a Hunter And a Pastry Chef w... 2006 1
Page: 1 of 100  Records: 998

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: film
 * Row count: 998
 * Column count: 13
 * Filename: phpvs_sakila.film.php
 * Created Wed, 22 Feb 2012 10:23:05 -0700
 * Primary key: film_id
 * Null fields: description, release_year, original_language_id, length, rating, special_features
 * Multi-key fields: title, language_id, original_language_id
 * All fields: film_id, title, description, release_year, language_id, original_language_id,
rental_duration, rental_rate, length, replacement_cost, rating,
special_features, last_update
*/

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

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

$opts['key'] = 'film_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
}


// Initialize toggle variables based on column number
$z5 get_cgi_var('z5');
$z6 get_cgi_var('z6');
$z7 get_cgi_var('z7');
$z8 get_cgi_var('z8');
$z9 get_cgi_var('z9');
$z10 get_cgi_var('z10');
$z11 get_cgi_var('z11');
$z12 get_cgi_var('z12');

// Toggle variables need to be persistent
$opts['cgi']['persist'] = array(
'z5' => $z5'z6' => $z6'z7' => $z7'z8' => $z8'z9' => $z9'z10' => $z10'z11' => $z11'z12' => $z12);

// Buffer the toggling links in order to facilitate their display
// above/below the form, or left/right the phpMyEdit form in TD tags
$my_link_buffer '';

if(
$list_mode_status){
   
$bqs ''// buffered query string (phpMyEdit system variables)
   
$ignore_keys = array(
      
'PME_sys_canceladd',
      
'PME_sys_cancelcopy',
      
'PME_sys_canceldelete',
      
'PME_sys_cancelview',
      
'PME_sys_cur_tab',
      
'PME_sys_moreadd',
      
'PME_sys_qfn',
      
'PME_sys_savechange'
   
);
   foreach(
$_REQUEST as $key => $val){
      if(
substr($key08) == 'PME_sys_' && !in_array($key$ignore_keys)){
         if(
is_array($val)){
            foreach(
$val as $k => $v){
               
$bqs .= '&'.$k.'='.$v;
            }
         }else{
            
$bqs .= '&'.$key.'='.$val;
         }
      }
   }
    
   
// calculate opposite values beginning with MySQL column #5
   
$tmp5 '&z5='.(empty($z5) ? 0);
   
$tmp6 '&z6='.(empty($z6) ? 0);
   
$tmp7 '&z7='.(empty($z7) ? 0);
   
$tmp8 '&z8='.(empty($z8) ? 0);
   
$tmp9 '&z9='.(empty($z9) ? 0);
   
$tmp10 '&z10='.(empty($z10) ? 0);
   
$tmp11 '&z11='.(empty($z11) ? 0);
   
$tmp12 '&z12='.(empty($z12) ? 0);

   
// template used to apply the above values
   
$tpl '&z5=%s&z6=%s&z7=%s&z8=%s&z9=%s&z10=%s&z11=%s&z12=%s';

    
// Note the progressive shift from one column to the next
   
$my_link_buffer .= "\n".'<p><hr>Additional Fields<hr>';
   
$my_link_buffer .= htmlLink(sprintf($tpl$tmp5$z6$z7$z8$z9$z10$z11$z12), 'Original Language ID'$z5);
   
$my_link_buffer .= htmlLink(sprintf($tpl$z5$tmp6$z7$z8$z9$z10$z11$z12), 'Rental Duration'$z6);
   
$my_link_buffer .= htmlLink(sprintf($tpl$z5$z6$tmp7$z8$z9$z10$z11$z12), 'Rental Rate'$z7);
   
$my_link_buffer .= htmlLink(sprintf($tpl$z5$z6$z7$tmp8$z9$z10$z11$z12), 'Length'$z8);
   
$my_link_buffer .= htmlLink(sprintf($tpl$z5$z6$z7$z8$tmp9$z10$z11$z12), 'Replacement Cost'$z9);
   
$my_link_buffer .= htmlLink(sprintf($tpl$z5$z6$z7$z8$z9$tmp10$z11$z12), 'Rating'$z10);
   
$my_link_buffer .= htmlLink(sprintf($tpl$z5$z6$z7$z8$z9$z10$tmp11$z12), 'Special Features'$z11);
   
$my_link_buffer .= htmlLink(sprintf($tpl$z5$z6$z7$z8$z9$z10$z11$tmp12), 'Last Update'$z12);
   
$my_link_buffer .= "\n".'</p><br>';
}

// Buffered toggle links can be echo'ed in a container table TD left/right/below phpMyEdit form


echo "\n".'<table border="0" cellpadding="0" cellspacing="0">';

echo 
"\n".'<tr valign="top">';

if(!empty(
$my_link_buffer)){
   echo 
"\n".'<td style="white-space:nowrap;background-color:#f0f8ff;padding:10px;border:1px solid #cccccc">'."\n";
   echo 
$my_link_buffer;
   echo 
"\n".'</td>';
   echo 
"\n".'<td width="15">&nbsp;</td>'// spacer
}

echo 
"\n".'<td>'."\n"// container for phpMyEdit form

// Begin phpMyEdit field arrays

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


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


// column 2: `description` blob - text
// flags: blob
// collation: utf8_general_ci
$opts['fdd']['description'] = array(
  
'default'    => '',
  
'help|ACP'   => 'Limit 65,535 characters',
  
'input'      => '',
  
'maxlen'     => 65535,
  
'name'       => 'Description',
  
'options'    => 'ACPVDFL',
  
'select'     => 'T',
  
'sqlw'       => 'IF($val_qas = "", NULL, $val_qas)',
  
'strip_tags|FL' => true,
  
'textarea'   => array('rows' => 20'cols' => 80),
  
'trimlen|FL' => 50,
  
'sort'       => false
);
$opts['fdd']['description']['js']['required'] = true;
$opts['fdd']['description']['js']['hint'] = 'An entry is required for Description';


// column 3: `release_year` year - year(4)
// flags: unsigned, zerofill
$opts['fdd']['release_year'] = array(
  
'css'        => array('postfix' => 'right-justify'),
  
'default'    => '',
  
'help|ACP'   => 'YYYY',
  
'input'      => '',
  
'maxlen'     => 4,
  
'name'       => 'Release Year',
  
'options'    => 'ACPVDFL',
  
'select'     => 'T',
  
'size'       => 4,
  
'sqlw'       => 'IF($val_qas = "", NULL, $val_qas)',
  
'sort'       => true
);
$opts['fdd']['release_year']['js']['required'] = true;
$opts['fdd']['release_year']['js']['hint'] = 'An entry is required for Release Year';


// column 4: `language_id` int - tinyint(3) unsigned
// flags: multiple_key, not_null, unsigned
$opts['fdd']['language_id'] = array(
  
'css'        => array('postfix' => 'right-justify'),
  
'default'    => '',
  
'help|ACP'   => 'Limit 3 digits',
  
'input'      => '',
  
'maxlen'     => 3,
  
'name'       => 'Language ID',
  
'options'    => 'ACPVDFL',
  
'select'     => 'T',
  
'size'       => 3,
  
'sqlw'       => 'TRIM("$val_as")',
  
'sort'       => true
);
// $opts['fdd']['language_id']['js']['required'] = true;
// $opts['fdd']['language_id']['js']['regexp'] = '/^[a-zA-Z]*$/'; // modify REGEXP to meet your needs
// $opts['fdd']['language_id']['js']['hint'] = 'An entry is required for Language ID';


// column 5: `original_language_id` int - tinyint(3) unsigned
// flags: multiple_key, unsigned
$opts['fdd']['original_language_id'] = array(
  
'css'        => array('postfix' => 'right-justify'),
  
'default'    => '',
  
'help|ACP'   => 'Limit 3 digits',
  
'input'      => '',
  
'maxlen'     => 3,
  
'name'       => 'Original Language ID',
  
'options'    => $z5 'ACPVDFL' 'ACPVD',
  
'select'     => 'T',
  
'size'       => 3,
  
'sqlw'       => 'IF($val_qas = "", NULL, $val_qas)',
  
'sort'       => true
);
// $opts['fdd']['original_language_id']['js']['required'] = true;
// $opts['fdd']['original_language_id']['js']['regexp'] = '/^[a-zA-Z]*$/'; // modify REGEXP to meet your needs
// $opts['fdd']['original_language_id']['js']['hint'] = 'An entry is required for Original Language ID';


// column 6: `rental_duration` int - tinyint(3) unsigned
// flags: not_null, unsigned
$opts['fdd']['rental_duration'] = array(
  
'css'        => array('postfix' => 'right-justify'),
  
'default'    => 3,
  
'help|ACP'   => 'Limit 3 digits',
  
'input'      => '',
  
'maxlen'     => 3,
  
'name'       => 'Rental Duration',
  
'options'    => $z6 'ACPVDFL' 'ACPVD',
  
'select'     => 'T',
  
'size'       => 3,
  
'sqlw'       => 'TRIM("$val_as")',
  
'sort'       => true
);
// $opts['fdd']['rental_duration']['js']['required'] = true;
// $opts['fdd']['rental_duration']['js']['regexp'] = '/^[a-zA-Z]*$/'; // modify REGEXP to meet your needs
// $opts['fdd']['rental_duration']['js']['hint'] = 'An entry is required for Rental Duration';


// column 7: `rental_rate` real - decimal(4,2)
// flags: not_null
$opts['fdd']['rental_rate'] = array(
  
'css'        => array('postfix' => 'right-justify'),
  
'default'    => 4.99,
  
'help|ACP'   => 'Limit 7 digits',
  
'input'      => '',
  
'maxlen'     => 7,
  
'number_format|VDFL' => array(2'.'','),
  
'name'       => 'Rental Rate',
  
'options'    => $z7 'ACPVDFL' 'ACPVD',
  
'select'     => 'T',
  
'size'       => 7,
  
'sqlw'       => 'TRIM("$val_as")',
  
'sort'       => true
);
// $opts['fdd']['rental_rate']['js']['required'] = true;
// $opts['fdd']['rental_rate']['js']['regexp'] = '/^[a-zA-Z]*$/'; // modify REGEXP to meet your needs
// $opts['fdd']['rental_rate']['js']['hint'] = 'An entry is required for Rental Rate';


// column 8: `length` int - smallint(5) unsigned
// flags: unsigned
$opts['fdd']['length'] = array(
  
'css'        => array('postfix' => 'right-justify'),
  
'default'    => '',
  
'help|ACP'   => 'Limit 5 digits',
  
'input'      => '',
  
'maxlen'     => 5,
//  'number_format|VDFL' => array(0, '.', ','),
  
'name'       => 'Length',
  
'options'    => $z8 'ACPVDFL' 'ACPVD',
  
'select'     => 'T',
  
'size'       => 5,
  
'sqlw'       => 'IF($val_qas = "", NULL, $val_qas)',
  
'sort'       => true
);
// $opts['fdd']['length']['js']['required'] = true;
// $opts['fdd']['length']['js']['regexp'] = '/^[a-zA-Z]*$/'; // modify REGEXP to meet your needs
// $opts['fdd']['length']['js']['hint'] = 'An entry is required for Length';


// column 9: `replacement_cost` real - decimal(5,2)
// flags: not_null
$opts['fdd']['replacement_cost'] = array(
  
'css'        => array('postfix' => 'right-justify'),
  
'default'    => 19.99,
  
'help|ACP'   => 'Limit 8 digits',
  
'input'      => '',
  
'maxlen'     => 8,
  
'number_format|VDFL' => array(2'.'','),
  
'name'       => 'Replacement Cost',
  
'options'    => $z9 'ACPVDFL' 'ACPVD',
  
'select'     => 'T',
  
'size'       => 8,
  
'sqlw'       => 'TRIM("$val_as")',
  
'sort'       => true
);
// $opts['fdd']['replacement_cost']['js']['required'] = true;
// $opts['fdd']['replacement_cost']['js']['regexp'] = '/^[a-zA-Z]*$/'; // modify REGEXP to meet your needs
// $opts['fdd']['replacement_cost']['js']['hint'] = 'An entry is required for Replacement Cost';


// column 10: `rating` enum - enum('G','PG','PG-13','R','NC-17')
// flags: enum
// collation: utf8_general_ci
$opts['fdd']['rating'] = array(
  
'css'        => array('postfix' => 'right-justify'),
  
'default'    => '',
  
'help|ACP'   => 'Select',
  
'input'      => '',
  
'maxlen'     => 5,
  
'name'       => 'Rating',
  
'options'    => $z10 'ACPVDFL' 'ACPVD',
  
'select'     => 'D',
  
'sqlw'       => 'IF($val_qas = "", NULL, $val_qas)',
  
'values'     => array('G','PG','PG-13','R','NC-17'), 
  
'sort'       => true
);
// $opts['fdd']['rating']['js']['required'] = true;
// $opts['fdd']['rating']['js']['regexp'] = '/^[a-zA-Z]*$/'; // modify REGEXP to meet your needs
// $opts['fdd']['rating']['js']['hint'] = 'An entry is required for Rating';


// column 11: `special_features` set - set('Trailers','Commentaries','Deleted Scenes','Behind the Scenes')
// flags: set
// collation: utf8_general_ci
$opts['fdd']['special_features'] = array(
  
'css'        => array('postfix' => 'right-justify'),
  
'default'    => '',
  
'help|ACP'   => 'Select',
  
'input'      => '',
  
'maxlen'     => 54,
  
'name'       => 'Special Features',
  
'options'    => $z11 'ACPVDFL' 'ACPVD',
  
'select'     => 'M',
  
'sqlw'       => 'IF($val_qas = "", NULL, $val_qas)',
  
'values'     => array('Trailers','Commentaries','Deleted Scenes','Behind the Scenes'), 
  
'sort'       => true
);
// $opts['fdd']['special_features']['js']['required'] = true;
// $opts['fdd']['special_features']['js']['regexp'] = '/^[a-zA-Z]*$/'; // modify REGEXP to meet your needs
// $opts['fdd']['special_features']['js']['hint'] = 'An entry is required for Special Features';


// column 12: `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'    => $z12 'ACPVDFL' 'VD',
  
'select'     => 'N',
  
'size'       => 19,
  
'sqlw'       => 'TRIM("$val_as")',
  
'sort'       => true
);
// $opts['fdd']['last_update']['js']['required'] = true;
// $opts['fdd']['last_update']['js']['regexp'] = '/^[a-zA-Z]*$/'; // modify REGEXP to meet your needs
// $opts['fdd']['last_update']['js']['hint'] = 'An entry is required for Last Update';

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

new 
phpMyEdit($opts);

echo 
"\n".'</td>'// close the phpMyEdit form

echo "\n".'</tr>';

echo 
"\n".'</table>';

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.