* beautified display of tables under Mozilla & NS6+ thanks to a fix from Detlev Stender

* the true MySQL type of columns is now displayed
This commit is contained in:
Loïc Chapeaux
2001-11-23 19:13:51 +00:00
parent dc91bc219a
commit ba1708a1a5

View File

@@ -24,18 +24,34 @@ $err_url = $goto
*/ */
if (!isset($param) || $param[0] == '') { if (!isset($param) || $param[0] == '') {
include('./header.inc.php3'); include('./header.inc.php3');
$result = @mysql_list_fields($db, $table);
// Gets the list and number of fields
$local_query = 'SHOW FIELDS FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table);
$result = @mysql_query($local_query);
if (!$result) { if (!$result) {
PMA_mysqlDie('', 'mysql_list_fields(' . $db . ', ' . $table . ')', '', $err_url); PMA_mysqlDie('', $local_query, '', $err_url);
} }
else { else {
// Gets the list and number of fields $fields_cnt = mysql_num_rows($result);
$fields_count = mysql_num_fields($result); while ($row = mysql_fetch_array($result)) {
for ($i = 0; $i < $fields_count; $i++) { $fields_list[] = $row['Field'];
$fields_list[] = mysql_field_name($result, $i); $type = $row['Type'];
$fields_type[] = mysql_field_type($result, $i); // reformat mysql query output - staybyte - 9. June 2001
$fields_len[] = mysql_field_len($result, $i); $shorttype = substr($type, 0, 3);
if ($shorttype == 'set' || $shorttype == 'enu') {
$type = eregi_replace(',', ', ', $type);
// Removes automatic MySQL escape format
$type = str_replace('\'\'', '\\\'', $type);
} }
$type = eregi_replace('BINARY', '', $type);
$type = eregi_replace('ZEROFILL', '', $type);
$type = eregi_replace('UNSIGNED', '', $type);
if (empty($type)) {
$type = '&nbsp;';
}
$fields_type[] = $type;
} // end while
mysql_free_result($result);
?> ?>
<form method="post" action="tbl_select.php3"> <form method="post" action="tbl_select.php3">
<input type="hidden" name="server" value="<?php echo $server; ?>" /> <input type="hidden" name="server" value="<?php echo $server; ?>" />
@@ -50,7 +66,7 @@ if (!isset($param) || $param[0] == '') {
<?php <?php
echo "\n"; echo "\n";
// Displays the list of the fields // Displays the list of the fields
for ($i = 0 ; $i < $fields_count; $i++) { for ($i = 0 ; $i < $fields_cnt; $i++) {
echo ' <option value="' . urlencode($fields_list[$i]) . '" selected="selected">' . htmlspecialchars($fields_list[$i]) . '</option>' . "\n"; echo ' <option value="' . urlencode($fields_list[$i]) . '" selected="selected">' . htmlspecialchars($fields_list[$i]) . '</option>' . "\n";
} }
?> ?>
@@ -75,17 +91,15 @@ if (!isset($param) || $param[0] == '') {
<th><?php echo $strValue; ?></th> <th><?php echo $strValue; ?></th>
</tr> </tr>
<?php <?php
for ($i = 0; $i < $fields_count; $i++) { for ($i = 0; $i < $fields_cnt; $i++) {
echo "\n"; echo "\n";
$bgcolor = ($i % 2) ? $cfgBgcolorOne : $cfgBgcolorTwo; $bgcolor = ($i % 2) ? $cfgBgcolorOne : $cfgBgcolorTwo;
$fieldsize = (($fields_len[$i] > 40) ? 40 : $fields_len[$i]);
$maxlength = (($fields_len[$i] < 8) ? 8 : $fields_len[$i]);
?> ?>
<tr bgcolor="<?php echo $bgcolor; ?>"> <tr>
<td><?php echo htmlspecialchars($fields_list[$i]); ?></td> <td bgcolor="<?php echo $bgcolor; ?>"><?php echo htmlspecialchars($fields_list[$i]); ?></td>
<td><?php echo $fields_type[$i]; ?></td> <td bgcolor="<?php echo $bgcolor; ?>"><?php echo $fields_type[$i]; ?></td>
<td> <td bgcolor="<?php echo $bgcolor; ?>">
<input type="text" name="fields[]" size="<?php echo $fieldsize; ?>" maxlength="<?php echo $maxlength; ?>" /> <input type="text" name="fields[]" size="40" />
<input type="hidden" name="names[]" value="<?php echo urlencode($fields_list[$i]); ?>" /> <input type="hidden" name="names[]" value="<?php echo urlencode($fields_list[$i]); ?>" />
<input type="hidden" name="types[]" value="<?php echo $fields_type[$i]; ?>" /> <input type="hidden" name="types[]" value="<?php echo $fields_type[$i]; ?>" />
</td> </td>
@@ -102,7 +116,7 @@ if (!isset($param) || $param[0] == '') {
<option value="--nil--"></option> <option value="--nil--"></option>
<?php <?php
echo "\n"; echo "\n";
for ($i = 0; $i < $fields_count; $i++) { for ($i = 0; $i < $fields_cnt; $i++) {
echo ' '; echo ' ';
echo '<option value="' . urlencode($fields_list[$i]) . '">' . htmlspecialchars($fields_list[$i]) . '</option>' . "\n"; echo '<option value="' . urlencode($fields_list[$i]) . '">' . htmlspecialchars($fields_list[$i]) . '</option>' . "\n";
} // end for } // end for