displays the selection form */ if (!isset($param) || $param[0] == '') { include('./header.inc.php3'); $result = @mysql_list_fields($db, $table); if (!$result) { mysql_die('', 'mysql_list_fields(' . $db . ', ' . $table . ')'); } else { // Gets the list and number of fields $fields_count = mysql_num_fields($result); for ($i = 0; $i < $fields_count; $i++) { $fields_list[] = mysql_field_name($result, $i); $fields_type[] = mysql_field_type($result, $i); $fields_len[] = mysql_field_len($result, $i); } ?>
do the work */ else { // Builds the query $sql_query = 'SELECT ' . backquote(urldecode($param[0])); $i = 0; $c = count($param); while ($i < $c) { if ($i > 0) { $sql_query .= ',' . backquote(urldecode($param[$i])); } $i++; } $sql_query .= ' FROM ' . backquote($table); // The where clause if ($where != '') { $sql_query .= ' WHERE ' . ((get_magic_quotes_gpc()) ? stripslashes($where) : $where); } else { $sql_query .= ' WHERE 1'; for ($i = 0; $i < count($fields); $i++) { if (!empty($fields) && $fields[$i] != '') { if (strtoupper($fields[$i]) == 'NULL' || strtoupper($fields[$i]) == 'NOT NULL') { $quot = ''; $cmp = 'IS'; } else if ($types[$i] == 'string' || $types[$i] == 'blob') { $quot = '\''; $cmp = 'LIKE'; if (get_magic_quotes_gpc()) { $fields[$i] = stripslashes($fields[$i]); } $fields[$i] = sql_addslashes($fields[$i], TRUE); } else if ($types[$i] == 'date' || $types[$i] == 'time') { $quot = '\''; $cmp = '='; } else if (strstr($fields[$i], '%')) { $quot = '\''; $cmp = 'LIKE'; } else if (substr($fields[$i], 0, 1) == '<' || substr($fields[$i], 0, 1) == '>') { $quot = ''; $cmp = ''; } else { $quot = ''; $cmp = '='; } // end if $sql_query .= ' AND ' . backquote(urldecode($names[$i])) . " $cmp $quot$fields[$i]$quot"; } // end if } // end for } // end if if ($orderField != '--nil--') { $sql_query .= ' ORDER BY ' . backquote(urldecode($orderField)) . ' ' . $order; } // end if $url_query = 'lang=' . $lang . '&server=' . $server . '&db=' . urlencode($db) . '&table=' . urlencode($table) . '&sql_query=' . urlencode($sql_query) . '&pos=0' . '&sessionMaxRows=' . $sessionMaxRows . '&goto='. $goto; header('Location: ' . $cfgPmaAbsoluteUri . 'sql.php3?' . $url_query); } ?>