home *** CD-ROM | disk | FTP | other *** search
/ Enter 2004 June / ENTER.ISO / files / xampp-win32-1.4.5-installer.exe / xampp / tbl_relation.php < prev    next >
Encoding:
PHP Script  |  2003-12-18  |  23.6 KB  |  579 lines

  1. <?php
  2. /* $Id: tbl_relation.php,v 2.5 2003/12/18 20:57:28 lem9 Exp $ */
  3. // vim: expandtab sw=4 ts=4 sts=4:
  4.  
  5. /**
  6.  * Gets some core libraries
  7.  */
  8. require_once('./libraries/grab_globals.lib.php');
  9. require_once('./libraries/common.lib.php');
  10. require('./tbl_properties_common.php');
  11. $url_query .= '&goto=tbl_properties.php';
  12.  
  13. // Note: in tbl_properties_table_info we get and display the table comment.
  14. // For InnoDB, this comment contains the REFER information but any update
  15. // has not been done yet (will be done in tbl_relation later).
  16. $avoid_show_comment = TRUE;
  17. require('./tbl_properties_table_info.php');
  18. require_once('./libraries/relation.lib.php');
  19.  
  20. $options_array = array('CASCADE' => 'CASCADE', 'SET_NULL' => 'SET NULL', 'NO_ACTION' => 'NO ACTION', 'RESTRICT' => 'RESTRICT');
  21.  
  22.          /**
  23.          * Generate dropdown choices
  24.          *
  25.          * @param   string   Message to display
  26.          * @param   string   Name of the <select> field
  27.          * @param   array    Choices for dropdown
  28.          * @return  string   The existing value (for selected)
  29.          *
  30.          * @access  public
  31.          */
  32. function PMA_generate_dropdown($dropdown_question,$radio_name,$choices,$selected_value) {
  33.     global $font_smallest;
  34.  
  35.     echo $dropdown_question . '  ';
  36.  
  37.     echo '<select name="' . $radio_name . '" style="font-size: ' . $font_smallest . '">' . "\n";
  38.     echo '<option value="nix" style="font-size: ' . $font_smallest . '" >--</option>' . "\n";
  39.  
  40.     foreach($choices AS $one_value => $one_label) {
  41.         echo '<option value="' . $one_value . '"';
  42.         if ($selected_value == $one_value) {
  43.             echo ' selected="selected" ';
  44.         }
  45.         echo ' style="font-size: ' . $font_smallest . '">' . $one_label . '</option>' . "\n";
  46.     }
  47.     echo '</select>' . "\n";
  48.     echo "\n";
  49. }
  50.  
  51.  
  52. /**
  53.  * Gets the relation settings
  54.  */
  55. $cfgRelation = PMA_getRelationsParam();
  56.  
  57.  
  58. /**
  59.  * Updates
  60.  */
  61.  
  62. if ($cfgRelation['relwork']) {
  63.     $existrel = PMA_getForeigners($db, $table, '', 'internal');
  64.     if ($tbl_type=='INNODB') {
  65.         $existrel_innodb = PMA_getForeigners($db, $table, '', 'innodb');
  66.     }
  67. }
  68. if ($cfgRelation['displaywork']) {
  69.     $disp     = PMA_getDisplayField($db, $table);
  70. }
  71. if ($cfgRelation['relwork']
  72.     && isset($submit_rel) && $submit_rel == 'true') {
  73.  
  74.     // u p d a t e s   f o r   I n t e r n a l    r e l a t i o n s
  75.  
  76.     foreach($destination AS $master_field => $foreign_string) {
  77.         if ($foreign_string != 'nix') {
  78.             list($foreign_db, $foreign_table, $foreign_field) = explode('.', $foreign_string);
  79.             if (!isset($existrel[$master_field])) {
  80.                 $upd_query  = 'INSERT INTO ' . PMA_backquote($cfgRelation['relation'])
  81.                             . '(master_db, master_table, master_field, foreign_db, foreign_table, foreign_field)'
  82.                             . ' values('
  83.                             . '\'' . PMA_sqlAddslashes($db) . '\', '
  84.                             . '\'' . PMA_sqlAddslashes($table) . '\', '
  85.                             . '\'' . PMA_sqlAddslashes($master_field) . '\', '
  86.                             . '\'' . PMA_sqlAddslashes($foreign_db) . '\', '
  87.                             . '\'' . PMA_sqlAddslashes($foreign_table) . '\','
  88.                             . '\'' . PMA_sqlAddslashes($foreign_field) . '\')';
  89.             } else if ($existrel[$master_field]['foreign_db'] . '.' .$existrel[$master_field]['foreign_table'] . '.' . $existrel[$master_field]['foreign_field'] != $foreign_string) {
  90.                 $upd_query  = 'UPDATE ' . PMA_backquote($cfgRelation['relation']) . ' SET'
  91.                             . ' foreign_db       = \'' . PMA_sqlAddslashes($foreign_db) . '\', '
  92.                             . ' foreign_table    = \'' . PMA_sqlAddslashes($foreign_table) . '\', '
  93.                             . ' foreign_field    = \'' . PMA_sqlAddslashes($foreign_field) . '\' '
  94.                             . ' WHERE master_db  = \'' . PMA_sqlAddslashes($db) . '\''
  95.                             . ' AND master_table = \'' . PMA_sqlAddslashes($table) . '\''
  96.                             . ' AND master_field = \'' . PMA_sqlAddslashes($master_field) . '\'';
  97.             } // end if... else....
  98.         } else if (isset($existrel[$master_field])) {
  99.             $upd_query      = 'DELETE FROM ' . PMA_backquote($cfgRelation['relation'])
  100.                             . ' WHERE master_db  = \'' . PMA_sqlAddslashes($db) . '\''
  101.                             . ' AND master_table = \'' . PMA_sqlAddslashes($table) . '\''
  102.                             . ' AND master_field = \'' . PMA_sqlAddslashes($master_field) . '\'';
  103.         } // end if... else....
  104.         if (isset($upd_query)) {
  105.             $upd_rs         = PMA_query_as_cu($upd_query);
  106.             unset($upd_query);
  107.         }
  108.     } // end while
  109.  
  110.  
  111.     // u p d a t e s   f o r   I n n o D B
  112.     // ( for now, one index name; we keep the definitions if the
  113.     // foreign db is not the same)
  114.     if (isset($destination_innodb)) {
  115.         foreach($destination_innodb AS $master_field => $foreign_string) {
  116.             if ($foreign_string != 'nix') {
  117.                 list($foreign_db, $foreign_table, $foreign_field) = explode('.', $foreign_string);
  118.                 if (!isset($existrel_innodb[$master_field])) {
  119.                     // no key defined for this field
  120.  
  121.                     // The next few lines are repeated below, so they
  122.                     // could be put in an include file
  123.                     // Note: I tried to enclose the db and table name with
  124.                     // backquotes but MySQL 4.0.16 did not like the syntax
  125.                     // (for example: `base2`.`table1` )
  126.  
  127.                     $upd_query  = 'ALTER TABLE ' . $table
  128.                                 . ' ADD FOREIGN KEY ('
  129.                                 . PMA_backquote(PMA_sqlAddslashes($master_field)) . ')'
  130.                                 . ' REFERENCES '
  131.                                 . PMA_backquote(PMA_sqlAddslashes($foreign_db) . '.'
  132.                                 . PMA_sqlAddslashes($foreign_table)) . '('
  133.                                 . PMA_backquote(PMA_sqlAddslashes($foreign_field)) . ')';
  134.  
  135.                     if (${$master_field . '_on_delete'} != 'nix') {
  136.                         $upd_query   .= ' ON DELETE ' . $options_array[${$master_field . '_on_delete'}];
  137.                     }
  138.                     if (${$master_field . '_on_update'} != 'nix') {
  139.                         $upd_query   .= ' ON UPDATE ' . $options_array[${$master_field . '_on_update'}];
  140.                     }
  141.  
  142.                     // end repeated code
  143.  
  144.                 } else if (($existrel_innodb[$master_field]['foreign_db'] . '.' .$existrel_innodb[$master_field]['foreign_table'] . '.' . $existrel_innodb[$master_field]['foreign_field'] != $foreign_string)
  145.                   || ( ${$master_field . '_on_delete'} != (!empty($existrel_innodb[$master_field]['on_delete']) ? $existrel_innodb[$master_field]['on_delete'] : ''))
  146.                   || ( ${$master_field . '_on_update'} != (!empty($existrel_innodb[$master_field]['on_update']) ? $existrel_innodb[$master_field]['on_update'] : ''))
  147.                        ) {
  148.                     // another foreign key is already defined for this field
  149.                     // or
  150.                     // an option has been changed for ON DELETE or ON UPDATE
  151.  
  152.                     // remove existing key
  153.                     if (PMA_MYSQL_INT_VERSION >= 40013) {
  154.                         $upd_query  = 'ALTER TABLE ' . $table
  155.                                     . ' DROP FOREIGN KEY '
  156.                                     . PMA_backquote($existrel_innodb[$master_field]['constraint']);
  157.  
  158.                         // I tried to send both in one query but it failed
  159.                         $upd_rs         = PMA_mysql_query($upd_query);
  160.                     }
  161.  
  162.                     // add another
  163.                     $upd_query  = 'ALTER TABLE ' . $table
  164.                                 . ' ADD FOREIGN KEY ('
  165.                                 . PMA_backquote(PMA_sqlAddslashes($master_field)) . ')'
  166.                                 . ' REFERENCES '
  167.                                 . PMA_backquote(PMA_sqlAddslashes($foreign_db) . '.'
  168.                                 . PMA_sqlAddslashes($foreign_table)) . '('
  169.                                 . PMA_backquote(PMA_sqlAddslashes($foreign_field)) . ')';
  170.  
  171.                     if (${$master_field . '_on_delete'} != 'nix') {
  172.                         $upd_query   .= ' ON DELETE ' . $options_array[${$master_field . '_on_delete'}];
  173.                     }
  174.                     if (${$master_field . '_on_update'} != 'nix') {
  175.                         $upd_query   .= ' ON UPDATE ' . $options_array[${$master_field . '_on_update'}];
  176.                     }
  177.  
  178.                 } // end if... else....
  179.             } else if (isset($existrel_innodb[$master_field])) {
  180.                     if (PMA_MYSQL_INT_VERSION >= 40013) {
  181.                         $upd_query  = 'ALTER TABLE ' . $table
  182.                                 . ' DROP FOREIGN KEY '
  183.                                 . PMA_backquote($existrel_innodb[$master_field]['constraint']);
  184.                     }
  185.             } // end if... else....
  186.  
  187.             if (isset($upd_query)) {
  188.                 $upd_rs         = PMA_mysql_query($upd_query);
  189.                 if (PMA_mysql_error() && mysql_errno() == 1005) {
  190.                     echo '<p class="warning">' . $strNoIndex . ' (' . $master_field .')</p>'  . PMA_showMySQLDocu('manual_Table_types', 'InnoDB_foreign_key_constraints') . "\n";
  191.                 }
  192.                 unset($upd_query);
  193.             }
  194.         } // end while
  195.     } // end if isset($destination_innodb)
  196.  
  197. } // end if
  198.  
  199.  
  200. // U p d a t e s   f o r   d i s p l a y   f i e l d
  201.  
  202. if ($cfgRelation['displaywork']
  203.     && isset($submit_show) && $submit_show == 'true') {
  204.  
  205.     if ($disp) {
  206.         if ($display_field != '') {
  207.             $upd_query = 'UPDATE ' . PMA_backquote($cfgRelation['table_info'])
  208.                        . ' SET display_field = \'' . PMA_sqlAddslashes($display_field) . '\''
  209.                        . ' WHERE db_name  = \'' . PMA_sqlAddslashes($db) . '\''
  210.                        . ' AND table_name = \'' . PMA_sqlAddslashes($table) . '\'';
  211.         } else {
  212.             $upd_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['table_info'])
  213.                        . ' WHERE db_name  = \'' . PMA_sqlAddslashes($db) . '\''
  214.                        . ' AND table_name = \'' . PMA_sqlAddslashes($table) . '\'';
  215.         }
  216.     } elseif ($display_field != '') {
  217.         $upd_query = 'INSERT INTO ' . PMA_backquote($cfgRelation['table_info'])
  218.                    . '(db_name, table_name, display_field) '
  219.                    . ' VALUES('
  220.                    . '\'' . PMA_sqlAddslashes($db) . '\','
  221.                    . '\'' . PMA_sqlAddslashes($table) . '\','
  222.                    . '\'' . PMA_sqlAddslashes($display_field) . '\')';
  223.     }
  224.  
  225.     if (isset($upd_query)) {
  226.         $upd_rs    = PMA_query_as_cu($upd_query);
  227.     }
  228. } // end if
  229.  
  230. if ($cfgRelation['commwork']
  231.     && isset($submit_comm) && $submit_comm == 'true') {
  232.     foreach($comment AS $key => $value) {
  233.         // garvin: I exported the snippet here to a function (relation.lib.php) , so it can be used multiple times throughout other pages where you can set comments.
  234.         PMA_setComment($db, $table, $key, $value);
  235.     }  // end while (transferred data)
  236. } // end if (commwork)
  237.  
  238. // If we did an update, refresh our data
  239. if ($cfgRelation['relwork']
  240.     && isset($submit_rel) && $submit_rel == 'true') {
  241.     $existrel = PMA_getForeigners($db, $table, '', 'internal');
  242.     if ($tbl_type=='INNODB') {
  243.         $existrel_innodb = PMA_getForeigners($db, $table, '', 'innodb');
  244.     }
  245. }
  246. if ($cfgRelation['displaywork']) {
  247.     $disp     = PMA_getDisplayField($db, $table);
  248. }
  249. if ($cfgRelation['commwork']) {
  250.     $comments = PMA_getComments($db, $table);
  251. }
  252.  
  253.  
  254. /**
  255.  * Dialog
  256.  */
  257. if ($cfgRelation['relwork']) {
  258.  
  259.     // To choose relations we first need all tables names in current db
  260.     // and if PMA version permits and the main table is innodb,
  261.     // we use SHOW TABLE STATUS because we need to find other InnoDB tables
  262.  
  263.     if ($tbl_type=='INNODB') {
  264.         $tab_query           = 'SHOW TABLE STATUS FROM ' . PMA_backquote($db);
  265.     // [0] of the row is the name
  266.     // [1] is the type
  267.     } else {
  268.         $tab_query           = 'SHOW TABLES FROM ' . PMA_backquote($db);
  269.     }
  270.     // [0] of the row is the name
  271.  
  272.     $tab_rs              = PMA_mysql_query($tab_query) or PMA_mysqlDie('', $tab_query, '', $err_url_0);
  273.     $selectboxall['nix'] = '--';
  274.     $selectboxall_innodb['nix'] = '--';
  275.  
  276.     while ($curr_table = @PMA_mysql_fetch_array($tab_rs)) {
  277.         if (($curr_table[0] != $table) && ($curr_table[0] != $cfg['Server']['relation'])) {
  278.             $fi_query = 'SHOW KEYS FROM ' . PMA_backquote($curr_table[0]);
  279.             $fi_rs    = PMA_mysql_query($fi_query) or PMA_mysqlDie('', $fi_query, '', $err_url_0);
  280.             if ($fi_rs && mysql_num_rows($fi_rs) > 0) {
  281.                 $seen_a_primary=FALSE;
  282.                 while ($curr_field = PMA_mysql_fetch_array($fi_rs)) {
  283.                     if (isset($curr_field['Key_name']) && $curr_field['Key_name'] == 'PRIMARY') {
  284.                         $seen_a_primary=TRUE;
  285.                         $field_full = $db . '.' .$curr_field['Table'] . '.' . $curr_field['Column_name'];
  286.                         $field_v    = $curr_field['Table'] . '->' . $curr_field['Column_name'];
  287.                         $selectboxall[$field_full] =  $field_v;
  288.                         // there could be more than one segment of the primary
  289.                         // so do not break
  290.  
  291.                         // Please watch here, tbl_type is INNODB but the
  292.                         // resulting value of SHOW KEYS is InnoDB
  293.  
  294.                         if ($tbl_type=='INNODB' && isset($curr_table[1]) && $curr_table[1]=='InnoDB') {
  295.                             $selectboxall_innodb[$field_full] =  $field_v;
  296.                         }
  297.  
  298.                     } else if (isset($curr_field['Non_unique']) && $curr_field['Non_unique'] == 0 && $seen_a_primary==FALSE) {
  299.                         // if we can't find a primary key we take any unique one
  300.                         // (in fact, we show all segments of unique keys
  301.                         //  and all unique keys)
  302.                         $field_full = $db . '.' . $curr_field['Table'] . '.' . $curr_field['Column_name'];
  303.                         $field_v    = $curr_field['Table'] . '->' . $curr_field['Column_name'];
  304.                         $selectboxall[$field_full] =  $field_v;
  305.                         if ($tbl_type=='INNODB' && isset($curr_table[1]) && $curr_table[1]=='InnoDB') {
  306.                             $selectboxall_innodb[$field_full] =  $field_v;
  307.                         }
  308.  
  309.                     // for InnoDB, any index is allowed
  310.                     } else if ($tbl_type=='INNODB' && isset($curr_table[1]) && $curr_table[1]=='InnoDB') {
  311.                         $field_full = $db . '.' . $curr_field['Table'] . '.' . $curr_field['Column_name'];
  312.                         $field_v    = $curr_field['Table'] . '->' . $curr_field['Column_name'];
  313.                         $selectboxall_innodb[$field_full] =  $field_v;
  314.  
  315.                     } // end if
  316.                 } // end while over keys
  317.             } // end if (mysql_num_rows)
  318.  
  319.         // Mike Beck - 24.07.02: i've been asked to add all keys of the
  320.         // current table (see bug report #574851)
  321.         }
  322.         else if ($curr_table[0] == $table) {
  323.             $fi_query = 'SHOW KEYS FROM ' . PMA_backquote($curr_table[0]);
  324.             $fi_rs    = PMA_mysql_query($fi_query) or PMA_mysqlDie('', $fi_query, '', $err_url_0);
  325.             if ($fi_rs && mysql_num_rows($fi_rs) > 0) {
  326.                 while ($curr_field = PMA_mysql_fetch_array($fi_rs)) {
  327.                     $field_full = $db . '.' . $curr_field['Table'] . '.' . $curr_field['Column_name'];
  328.                     $field_v    = $curr_field['Table'] . '->' . $curr_field['Column_name'];
  329.                     $selectboxall[$field_full] =  $field_v;
  330.                     if ($tbl_type=='INNODB' && isset($curr_table[1]) && $curr_table[1]=='InnoDB') {
  331.                         $selectboxall_innodb[$field_full] =  $field_v;
  332.                     }
  333.                 } // end while
  334.             } // end if (mysql_num_rows)
  335.         }
  336.     } // end while over tables
  337.  
  338. } // end if
  339.  
  340.  
  341. // Now find out the columns of our $table
  342. $col_query = 'SHOW COLUMNS FROM ' . PMA_backquote($table);
  343. $col_rs    = PMA_mysql_query($col_query) or PMA_mysqlDie('', $col_query, '', $err_url_0);
  344.  
  345. if ($col_rs && mysql_num_rows($col_rs) > 0) {
  346.     while ($row = PMA_mysql_fetch_array($col_rs)) {
  347.         $save_row[] = $row;
  348.     }
  349.     $saved_row_cnt  = count($save_row);
  350.  
  351.     ?>
  352. <form method="post" action="tbl_relation.php">
  353.     <?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
  354.     <input type="hidden" name="submit_rel" value="true" />
  355.  
  356.     <table>
  357.     <tr>
  358.         <th colspan="4" align="center"><b><?php echo $strLinksTo; ?></b></th>
  359.     </tr>
  360.     <tr>
  361.         <th></th><th><b><?php echo $strInternalRelations;
  362.         if ($tbl_type=='INNODB') {
  363.             echo ' (*)';
  364.         }
  365.         ?></b></th>
  366.         <?php
  367.         if ($tbl_type=='INNODB') {
  368.             echo '<th colspan="2">InnoDB';
  369.             if (PMA_MYSQL_INT_VERSION < 40013) {
  370.                 echo ' (**)';
  371.             }
  372.             echo '</th>';
  373.         }
  374.         ?>
  375.     </tr>
  376.     <?php
  377.     for ($i = 0; $i < $saved_row_cnt; $i++) {
  378.         $myfield = $save_row[$i]['Field'];
  379.         echo "\n";
  380.         ?>
  381.     <tr>
  382.         <th><?php echo $save_row[$i]['Field']; ?></th>
  383.         <td>
  384.             <select name="destination[<?php echo htmlspecialchars($save_row[$i]['Field']); ?>]">
  385.         <?php
  386.         echo "\n";
  387.  
  388.         // PMA internal relations
  389.         if (isset($existrel[$myfield])) {
  390.             $foreign_field    = $existrel[$myfield]['foreign_db'] . '.'
  391.                      . $existrel[$myfield]['foreign_table'] . '.'
  392.                      . $existrel[$myfield]['foreign_field'];
  393.         } else {
  394.             $foreign_field    = FALSE;
  395.         }
  396.         $seen_key = FALSE;
  397.         foreach($selectboxall AS $key => $value) {
  398.             echo '                '
  399.                  . '<option value="' . htmlspecialchars($key) . '"';
  400.             if ($foreign_field && $key == $foreign_field) {
  401.                 echo ' selected="selected"';
  402.                 $seen_key = TRUE;
  403.             }
  404.             echo '>' . $value . '</option>'. "\n";
  405.         } // end while
  406.  
  407.         // if the link defined in relationtable points to a foreign field
  408.         // that is not a key in the foreign table, we show the link
  409.         // (will not be shown with an arrow)
  410.         if ($foreign_field && !$seen_key) {
  411.             echo '                '
  412.                  . '<option value="' . htmlspecialchars($foreign_field) . '"';
  413.             echo ' selected="selected"';
  414.             echo '>' . $foreign_field . '</option>'. "\n";
  415.         }
  416.         ?>
  417.             </select>
  418.         </td>
  419.         <?php
  420.         if ($tbl_type=='INNODB') {
  421.         ?>
  422.         <td>
  423.             <select name="destination_innodb[<?php echo htmlspecialchars($save_row[$i]['Field']); ?>]">
  424.         <?php
  425.             if (isset($existrel_innodb[$myfield])) {
  426.                 $foreign_field    = $existrel_innodb[$myfield]['foreign_db'] . '.'
  427.                          . $existrel_innodb[$myfield]['foreign_table'] . '.'
  428.                          . $existrel_innodb[$myfield]['foreign_field'];
  429.             } else {
  430.                 $foreign_field    = FALSE;
  431.             }
  432.  
  433.             $found_foreign_field = FALSE;
  434.             foreach($selectboxall_innodb AS $key => $value) {
  435.                 echo '                '
  436.                      . '<option value="' . htmlspecialchars($key) . '"';
  437.                 if ($foreign_field && $key == $foreign_field) {
  438.                     echo ' selected="selected"';
  439.                     $found_foreign_field = TRUE;
  440.                 }
  441.                 echo '>' . $value . '</option>'. "\n";
  442.             } // end while
  443.  
  444.             // we did not find the foreign field in the tables of current db,
  445.             // must be defined in another db so show it to avoid erasing it
  446.             if (!$found_foreign_field && $foreign_field) {
  447.                 echo '                '
  448.                      . '<option value="' . htmlspecialchars($foreign_field) . '"';
  449.                 echo ' selected="selected"';
  450.                 echo '>' . $foreign_field . '</option>'. "\n";
  451.             }
  452.  
  453.         ?>
  454.                 </select>
  455.         </td>
  456.         <td>
  457.         <?php
  458.               PMA_generate_dropdown('ON DELETE',
  459.                   htmlspecialchars($save_row[$i]['Field']) . '_on_delete',
  460.                   $options_array,
  461.                   (isset($existrel_innodb[$myfield]['on_delete']) ? $existrel_innodb[$myfield]['on_delete']: '') );
  462.  
  463.               echo '   ';
  464.  
  465.               PMA_generate_dropdown('ON UPDATE',
  466.                   htmlspecialchars($save_row[$i]['Field']) . '_on_update',
  467.                   $options_array,
  468.                   (isset($existrel_innodb[$myfield]['on_update']) ? $existrel_innodb[$myfield]['on_update']: '') );
  469.  
  470.         }
  471.         ?>
  472.         </td>
  473.     </tr>
  474.         <?php
  475.     } // end for
  476.  
  477.     echo "\n";
  478.     ?>
  479.     <tr>
  480.         <td colspan="2" align="center">
  481.             <input type="submit" value="<?php echo '  ' . $strGo . '  '; ?>" />
  482.         </td>
  483.     </tr>
  484.     </table>
  485.     <?php
  486.         if ($tbl_type=='INNODB') {
  487.             echo $strInternalNotNecessary . '<br />';
  488.                 if (PMA_MYSQL_INT_VERSION < 40013) {
  489.                     echo '** ' . sprintf($strUpgrade, 'MySQL', '4.0.13') . '<br />';
  490.                 }
  491.         }
  492.     ?>
  493. </form>
  494.  
  495.     <?php
  496.     if ($cfgRelation['displaywork']) {
  497.         // Get "display_field" infos
  498.         $disp = PMA_getDisplayField($db, $table);
  499.  
  500.         echo "\n";
  501.         ?>
  502. <form method="post" action="tbl_relation.php">
  503.     <?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
  504.     <input type="hidden" name="submit_show" value="true" />
  505.  
  506.     <p><?php echo $strChangeDisplay . ': '; ?>
  507.     <select name="display_field" onchange="this.form.submit();">
  508.         <option value="">---</option>
  509.         <?php
  510.         echo "\n";
  511.         mysql_data_seek($col_rs, 0);
  512.         while ($row = @PMA_mysql_fetch_array($col_rs)) {
  513.             echo '        <option value="' . htmlspecialchars($row['Field']) . '"';
  514.             if (isset($disp) && $row['Field'] == $disp) {
  515.                 echo ' selected="selected"';
  516.             }
  517.             echo '>' . htmlspecialchars($row['Field']) . '</option>'. "\n";
  518.         } // end while
  519.         ?>
  520.     </select>
  521.     <script type="text/javascript" language="javascript">
  522.     <!--
  523.     // Fake js to allow the use of the <noscript> tag
  524.     //-->
  525.     </script>
  526.     <noscript>
  527.         <input type="submit" value="<?php echo $strGo; ?>" />
  528.     </noscript>
  529. </form>
  530. </p>
  531.         <?php
  532.     } // end if (displayworks)
  533.  
  534.     if ($cfgRelation['commwork']) {
  535.  
  536.         echo "\n";
  537.         ?>
  538. <form method="post" action="tbl_relation.php">
  539.     <?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
  540.     <input type="hidden" name="submit_comm" value="true" />
  541.  
  542.     <table>
  543.     <tr>
  544.         <th colspan="2" align="center"><b><?php echo $strComments; ?></b></th>
  545.     </tr>
  546.         <?php
  547.         for ($i = 0; $i < $saved_row_cnt; $i++) {
  548.             $field = $save_row[$i]['Field'];
  549.             echo "\n";
  550.             ?>
  551.     <tr>
  552.         <th><?php echo $field; ?></th>
  553.         <td>
  554.             <input type="text" name="comment[<?php echo $field; ?>]" value="<?php echo (isset($comments[$field]) ?  htmlspecialchars($comments[$field]) : ''); ?>" />
  555.         </td>
  556.     </tr>
  557.             <?php
  558.         } // end for
  559.  
  560.         echo "\n";
  561.         ?>
  562.     <tr>
  563.         <td colspan="2" align="center">
  564.             <input type="submit" value="<?php echo $strGo; ?>" />
  565.         </td>
  566.     </tr>
  567.     </table>
  568. </form>
  569.         <?php
  570.     } //    end if (comments work)
  571. } // end if (we have columns in this table)
  572.  
  573.  
  574. /**
  575.  * Displays the footer
  576.  */
  577. require_once('./footer.inc.php');
  578. ?>
  579.