split between NULL value and empty field

This commit is contained in:
Loïc Chapeaux
2001-09-08 22:45:58 +00:00
parent 20fbb53055
commit 23c23a2ce2
2 changed files with 42 additions and 37 deletions

View File

@@ -568,8 +568,11 @@ if (!defined('__LIB_DISPLAY_TBL__')){
// table being displayed has one or more keys; but to display // table being displayed has one or more keys; but to display
// delete/edit options correctly for tables without keys. // delete/edit options correctly for tables without keys.
while ($row = mysql_fetch_row($dt_result)) { // loic1: use 'mysql_fetch_array' rather than 'mysql_fetch_row' to get
$bgcolor = ($foo % 2) ? $GLOBALS['cfgBgcolorOne'] : $GLOBALS['cfgBgcolorTwo']; // the NULL values
while ($row = mysql_fetch_array($dt_result)) {
$bgcolor = ($foo % 2) ? $GLOBALS['cfgBgcolorOne'] : $GLOBALS['cfgBgcolorTwo'];
?> ?>
<tr bgcolor="<?php echo $bgcolor; ?>"> <tr bgcolor="<?php echo $bgcolor; ?>">
@@ -587,11 +590,10 @@ if (!defined('__LIB_DISPLAY_TBL__')){
for ($i = 0; $i < $fields_cnt; ++$i) { for ($i = 0; $i < $fields_cnt; ++$i) {
$primary = $fields_meta[$i]; $primary = $fields_meta[$i];
$condition = ' ' . backquote($primary->name) . ' '; $condition = ' ' . backquote($primary->name) . ' ';
if (!isset($row[$i])) { if (!isset($row[$primary->name])) {
$row[$i] = '';
$condition .= 'IS NULL AND'; $condition .= 'IS NULL AND';
} else { } else {
$condition .= '= \'' . sql_addslashes($row[$i]) . '\' AND'; $condition .= '= \'' . sql_addslashes($row[$primary->name]) . '\' AND';
} }
if ($primary->primary_key > 0) { if ($primary->primary_key > 0) {
$primary_key .= $condition; $primary_key .= $condition;
@@ -610,12 +612,6 @@ if (!defined('__LIB_DISPLAY_TBL__')){
$uva_condition = urlencode(ereg_replace(' ?AND$', '', $uva_condition)); $uva_condition = urlencode(ereg_replace(' ?AND$', '', $uva_condition));
} // end if (1.1) } // end if (1.1)
// 1.2 Results from a "SHOW PROCESSLIST" statement -> gets the
// process id
else if ($is_display['del_lnk'] == 'kp') {
$pma_pid = $row[0];
}
// 1.2 Defines the urls for the modify/delete link(s) // 1.2 Defines the urls for the modify/delete link(s)
$url_query = 'lang=' . $lang $url_query = 'lang=' . $lang
. '&server=' . $server . '&server=' . $server
@@ -662,13 +658,13 @@ if (!defined('__LIB_DISPLAY_TBL__')){
. '?lang=' . $lang . '?lang=' . $lang
. '&server=' . $server . '&server=' . $server
. '&db=mysql' . '&db=mysql'
. '&sql_query=' . urlencode('KILL ' . $pma_pid) . '&sql_query=' . urlencode('KILL ' . $row['Id'])
. '&goto=main.php3'; . '&goto=main.php3';
$js_conf = 'KILL ' . $pma_pid; $js_conf = 'KILL ' . $row['Id'];
$del_str = $GLOBALS['strKill']; $del_str = $GLOBALS['strKill'];
} // end if (1.2.1) } // end if (1.2.2)
// 1.2.3 Displays the links at left if required // 1.3 Displays the links at left if required
if ($GLOBALS['cfgModifyDeleteAtLeft']) { if ($GLOBALS['cfgModifyDeleteAtLeft']) {
if (!empty($edit_url)) { if (!empty($edit_url)) {
?> ?>
@@ -688,19 +684,18 @@ if (!defined('__LIB_DISPLAY_TBL__')){
</td> </td>
<?php <?php
} }
} // end if (1.2.3) } // end if (1.3)
echo "\n"; echo "\n";
} // end if (1) } // end if (1)
// 2. Displays the rows' values // 2. Displays the rows' values
for ($i = 0; $i < $fields_cnt; ++$i) { for ($i = 0; $i < $fields_cnt; ++$i) {
if (!isset($row[$i])) {
$row[$i] = '';
}
$primary = $fields_meta[$i]; $primary = $fields_meta[$i];
if ($primary->numeric == 1) { if ($primary->numeric == 1) {
if ($row[$i] != '') { if (!isset($row[$primary->name])) {
echo ' <td align="right">' . $row[$i] . '</td>' . "\n"; echo ' <td align="right"><i>NULL</i></td>' . "\n";
} else if ($row[$i] != '') {
echo ' <td align="right">' . $row[$primary->name] . '</td>' . "\n";
} else { } else {
echo ' <td align="right">&nbsp;</td>' . "\n"; echo ' <td align="right">&nbsp;</td>' . "\n";
} }
@@ -713,28 +708,32 @@ if (!defined('__LIB_DISPLAY_TBL__')){
if (eregi('BINARY', $field_flags)) { if (eregi('BINARY', $field_flags)) {
echo ' <td align="center">[BLOB]</td>' . "\n"; echo ' <td align="center">[BLOB]</td>' . "\n";
} else { } else {
if (strlen($row[$i]) > $GLOBALS['cfgLimitChars'] && ($dontlimitchars != 1)) { if (!isset($row[$primary->name])) {
$row[$i] = substr($row[$i], 0, $GLOBALS['cfgLimitChars']) . '...'; echo ' <td><i>NULL</i></td>' . "\n";
} } else if ($row[$primary->name] != '') {
// loic1 : displays <cr>/<lf> if (strlen($row[$primary->name]) > $GLOBALS['cfgLimitChars'] && ($dontlimitchars != 1)) {
if ($row[$i] != '') { $row[$primary->name] = substr($row[$primary->name], 0, $GLOBALS['cfgLimitChars']) . '...';
$row[$i] = ereg_replace("((\015\012)|(\015)|(\012))+", '<br />', htmlspecialchars($row[$i])); }
echo ' <td>' . $row[$i] . '</td>' . "\n"; // loic1 : displays <cr>/<lf>
$row[$primary->name] = ereg_replace("((\015\012)|(\015)|(\012))+", '<br />', htmlspecialchars($row[$primary->name]));
echo ' <td>' . $row[$primary->name] . '</td>' . "\n";
} else { } else {
echo ' <td>&nbsp;</td>' . "\n"; echo ' <td>&nbsp;</td>' . "\n";
} }
} }
} else { } else {
// loic1 : displays <cr>/<lf> if (!isset($row[$primary->name])) {
if ($row[$i] != '') { echo ' <td><i>NULL</i></td>' . "\n";
} else if ($row[$primary->name] != '') {
// loic1: Cut text/blob fields even if $cfgShowBlob is true // loic1: Cut text/blob fields even if $cfgShowBlob is true
if (eregi('BLOB', $primary->type)) { if (eregi('BLOB', $primary->type)) {
if (strlen($row[$i]) > $GLOBALS['cfgLimitChars'] && ($dontlimitchars != 1)) { if (strlen($row[$primary->name]) > $GLOBALS['cfgLimitChars'] && ($dontlimitchars != 1)) {
$row[$i] = substr($row[$i], 0, $GLOBALS['cfgLimitChars']) . '...'; $row[$primary->name] = substr($row[$primary->name], 0, $GLOBALS['cfgLimitChars']) . '...';
} }
} }
$row[$i] = ereg_replace("((\015\012)|(\015)|(\012))+", '<br />', htmlspecialchars($row[$i])); // loic1 : displays <cr>/<lf>
echo ' <td>' . $row[$i] . '</td>' . "\n"; $row[$primary->name] = ereg_replace("((\015\012)|(\015)|(\012))+", '<br />', htmlspecialchars($row[$primary->name]));
echo ' <td>' . $row[$primary->name] . '</td>' . "\n";
} else { } else {
echo ' <td>&nbsp;</td>' . "\n"; echo ' <td>&nbsp;</td>' . "\n";
} }

View File

@@ -122,8 +122,14 @@ for ($i = 0; $i < $fields_cnt; $i++) {
$special_chars = htmlspecialchars($row[$field]); $special_chars = htmlspecialchars($row[$field]);
$data = $row[$field]; $data = $row[$field];
$backup_field = '<input type="hidden" name="fields_prev[' . urlencode($field) . ']" value="' . urlencode($data) . '" />'; $backup_field = '<input type="hidden" name="fields_prev[' . urlencode($field) . ']" value="' . urlencode($data) . '" />';
} else if (isset($primary_key)) {
$special_chars = 'NULL';
$data = '';
$backup_field = '<input type="hidden" name="fields_prev[' . urlencode($field) . ']" value="NULL" />';
} else { } else {
$data = $special_chars = $backup_field = ''; $special_chars = '';
$data = '';
$backup_field = '';
} }
// Change by Bernard M. Piller <bernard@bmpsystems.com> // Change by Bernard M. Piller <bernard@bmpsystems.com>
@@ -173,7 +179,7 @@ for ($i = 0; $i < $fields_cnt; $i++) {
?> ?>
<td> <td>
<?php echo $backup_field . "\n"; ?> <?php echo $backup_field . "\n"; ?>
<textarea name="fields[<?php echo urlencode($field); ?>]" rows="<?php echo $cfgTextareaRows; ?>" cols="<?php echo $cfgTextareaCols; ?>"><?php if (!empty($special_chars)) echo $special_chars; ?></textarea> <textarea name="fields[<?php echo urlencode($field); ?>]" rows="<?php echo $cfgTextareaRows; ?>" cols="<?php echo $cfgTextareaCols; ?>"><?php echo $special_chars; ?></textarea>
</td> </td>
<?php <?php
echo "\n"; echo "\n";
@@ -319,7 +325,7 @@ for ($i = 0; $i < $fields_cnt; $i++) {
?> ?>
<td> <td>
<?php echo $backup_field . "\n"; ?> <?php echo $backup_field . "\n"; ?>
<textarea name="fields[<?php echo urlencode($field); ?>]" rows="<?php echo $cfgTextareaRows; ?>" cols="<?php echo $cfgTextareaCols; ?>"><?php if (!empty($special_chars)) echo $special_chars; ?></textarea> <textarea name="fields[<?php echo urlencode($field); ?>]" rows="<?php echo $cfgTextareaRows; ?>" cols="<?php echo $cfgTextareaCols; ?>"><?php echo $special_chars; ?></textarea>
</td> </td>
<?php <?php
} else { } else {