📄 tbl_select.php
字号:
// ]]> </script> <?php } elseif (strncasecmp($fields_type[$i], 'enum', 4) == 0) { // e n u m s $enum_value=explode(', ', str_replace("'", '', substr($fields_type[$i], 5, -1))); $cnt_enum_value = count($enum_value); echo ' <select name="fields[' . $i . '][]"' .' multiple="multiple" size="' . min(3, $cnt_enum_value) . '">' . "\n"; for ($j = 0; $j < $cnt_enum_value; $j++) { echo ' <option value="' . $enum_value[$j] . '">' . $enum_value[$j] . '</option>'; } // end for echo ' </select>' . "\n"; } else { // o t h e r c a s e s echo ' <input type="text" name="fields[' . $i . ']"' .' size="40" class="textfield" id="field_' . $i . '" />' . "\n"; }; $type = $fields_type[$i]; if ($type == 'date' || $type == 'datetime' || substr($type, 0, 9) == 'timestamp') { ?> <script type="text/javascript"> //<![CDATA[ document.write('<a title="<?php echo $strCalendar;?>" href="javascript:openCalendar(\'<?php echo PMA_generate_common_url();?>\', \'insertForm\', \'field_<?php echo ($i); ?>\', \'<?php echo (substr($type, 0, 9) == 'timestamp') ? 'datetime' : substr($type, 0, 9); ?>\')"><img class="calendar" src="<?php echo $pmaThemeImage; ?>b_calendar.png" alt="<?php echo $strCalendar; ?>"/></a>'); //]]> </script> <?php } ?> <input type="hidden" name="names[<?php echo $i; ?>]" value="<?php echo htmlspecialchars($fields_list[$i]); ?>" /> <input type="hidden" name="types[<?php echo $i; ?>]" value="<?php echo $fields_type[$i]; ?>" /> <input type="hidden" name="collations[<?php echo $i; ?>]" value="<?php echo $fields_collation[$i]; ?>" /> </td> </tr> <?php } // end for ?> </tbody> </table></fieldset><?php PMA_generate_slider_effect('searchoptions', $strOptions);?><fieldset id="fieldset_select_fields"> <legend><?php echo $strSelectFields; ?></legend> <select name="param[]" size="<?php echo min($fields_cnt, 10); ?>" multiple="multiple"> <?php // Displays the list of the fields foreach ($fields_list as $each_field) { echo ' ' .'<option value="' . htmlspecialchars($each_field) . '"' .' selected="selected">' . htmlspecialchars($each_field) .'</option>' . "\n"; } ?> </select> <input type="checkbox" name="distinct" value="DISTINCT" id="oDistinct" /> <label for="oDistinct">DISTINCT</label></fieldset><fieldset id="fieldset_search_conditions"> <legend><?php echo '<em>' . $strOr . '</em> ' .$strAddSearchConditions; ?></legend><?php echo PMA_showMySQLDocu('SQL-Syntax', 'Functions'); ?><input type="text" name="where" class="textfield" size="64" /></fieldset><fieldset id="fieldset_limit_rows"> <legend><?php echo $strLimitNumRows; ?></legend> <input type="text" size="4" name="session_max_rows" value="<?php echo $GLOBALS['cfg']['MaxRows']; ?>" class="textfield" /></fieldset><fieldset id="fieldset_display_order"> <legend><?php echo $strDisplayOrder; ?></legend> <select name="orderField" style="vertical-align: middle"> <option value="--nil--"></option> <?php foreach ($fields_list as $each_field) { echo ' ' .'<option value="' . htmlspecialchars($each_field) . '">' .htmlspecialchars($each_field) . '</option>' . "\n"; } // end for ?> </select><?php $choices = array( 'ASC' => $strAscending, 'DESC' => $strDescending ); PMA_generate_html_radio('order', $choices, 'ASC', false, true, "formelement"); unset($choices);?></fieldset></div></fieldset><fieldset class="tblFooters"> <input type="hidden" name="max_number_of_fields" value="<?php echo $fields_cnt; ?>" /> <input type="submit" name="submit" value="<?php echo $strGo; ?>" /></fieldset></form> <?php require_once './libraries/footer.inc.php';}/** * Selection criteria have been submitted -> do the work */else { // Builds the query $sql_query = 'SELECT ' . (isset($distinct) ? 'DISTINCT ' : ''); // if all fields were selected to display, we do a SELECT * // (more efficient and this helps prevent a problem in IE // if one of the rows is edited and we come back to the Select results) if (count($param) == $max_number_of_fields) { $sql_query .= '* '; } else { $param = PMA_backquote($param); $sql_query .= implode(', ', $param); unset($param); } // end if $sql_query .= ' FROM ' . PMA_backquote($table); // The where clause if (trim($where) != '') { $sql_query .= ' WHERE ' . $where; } else { $w = $charsets = array(); $cnt_func = count($func); reset($func); while (list($i, $func_type) = each($func)) { list($charsets[$i]) = explode('_', $collations[$i]); if (isset($GLOBALS['cfg']['UnaryOperators'][$func_type]) && $GLOBALS['cfg']['UnaryOperators'][$func_type] == 1) { $fields[$i] = ''; $w[] = PMA_backquote($names[$i]) . ' ' . $func_type; } elseif (strncasecmp($types[$i], 'enum', 4) == 0) { if (!empty($fields[$i])) { if (!is_array($fields[$i])) { $fields[$i] = explode(',', $fields[$i]); } $enum_selected_count = count($fields[$i]); if ($func_type == '=' && $enum_selected_count > 1) { $func_type = $func[$i] = 'IN'; $parens_open = '('; $parens_close = ')'; } elseif ($func_type == '!=' && $enum_selected_count > 1) { $func_type = $func[$i] = 'NOT IN'; $parens_open = '('; $parens_close = ')'; } else { $parens_open = ''; $parens_close = ''; } $enum_where = '\'' . PMA_sqlAddslashes($fields[$i][0]) . '\''; for ($e = 1; $e < $enum_selected_count; $e++) { $enum_where .= ', \'' . PMA_sqlAddslashes($fields[$i][$e]) . '\''; } $w[] = PMA_backquote($names[$i]) . ' ' . $func_type . ' ' . $parens_open . $enum_where . $parens_close; } } elseif ($fields[$i] != '') { // For these types we quote the value. Even if it's another type (like INT), // for a LIKE we always quote the value. MySQL converts strings to numbers // and numbers to strings as necessary during the comparison if (preg_match('@char|binary|blob|text|set|date|time|year@i', $types[$i]) || strpos(' ' . $func_type, 'LIKE')) { $quot = '\''; } else { $quot = ''; } // LIKE %...% if ($func_type == 'LIKE %...%') { $func_type = 'LIKE'; $fields[$i] = '%' . $fields[$i] . '%'; } $w[] = PMA_backquote($names[$i]) . ' ' . $func_type . ' ' . $quot . PMA_sqlAddslashes($fields[$i]) . $quot; } // end if } // end for if ($w) { $sql_query .= ' WHERE ' . implode(' AND ', $w); } } // end if if ($orderField != '--nil--') { $sql_query .= ' ORDER BY ' . PMA_backquote($orderField) . ' ' . $order; } // end if require './sql.php';}?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -