6 * Gets some core libraries
8 require('./grab_globals.inc.php3');
9 require('./lib.inc.php3');
13 * Not selection yet required -> displays the selection form
15 if (!isset($param) ||
$param[0] == '') {
16 include('./header.inc.php3');
17 $result = mysql_list_fields($db, $table);
22 // Gets the list and number of fields
23 $fields_count = mysql_num_fields($result);
24 for ($i = 0; $i < $fields_count; $i++
) {
25 $fields_list[] = mysql_field_name($result, $i);
26 $fields_type[] = mysql_field_type($result, $i);
27 $fields_len[] = mysql_field_len($result, $i);
30 <form method
="post" action
="tbl_select.php3">
31 <input type
="hidden" name
="server" value
="<?php echo $server; ?>" />
32 <input type
="hidden" name
="lang" value
="<?php echo $lang; ?>" />
33 <input type
="hidden" name
="db" value
="<?php echo $db; ?>" />
34 <input type
="hidden" name
="table" value
="<?php echo $table; ?>" />
35  
; 
; 
; 
; 
;
36 <?php
echo $strSelectFields; ?
> 
;:<br
/>
37  
; 
; 
; 
; 
;
38 <select name
="param[]" size
="10" multiple
="multiple">
41 // Displays the list of the fields
42 for ($i = 0 ; $i < $fields_count; $i++
) {
43 echo ' <option value="' . urlencode($fields_list[$i]) . '" selected="selected">' . htmlspecialchars($fields_list[$i]) . '</option>' . "\n";
49 <div style
="margin-bottom: 10px">
50 <?php
echo $strDisplay; ?
> 
;
51 <input type
="text" size
="4" name
="sessionMaxRows" value
="<?php echo $cfgMaxRows; ?>" />
52 <?php
echo $strLimitNumRows . "\n"; ?
>
56 <?php
echo $strAddSearchConditions; ?
><br
/>
57 <input type
="text" name
="where" /> 
;
58 <?php
print show_docu("manual_Reference.html#Functions") . "\n"; ?
>
60 <?php
echo '<i>' . $strOr . '</i> ' . $strDoAQuery; ?
><br
/>
61 <table border
="<?php echo $cfgBorder; ?>">
63 <th
><?php
echo $strField; ?
></th
>
64 <th
><?php
echo $strType; ?
></th
>
65 <th
><?php
echo $strValue; ?
></th
>
69 for ($i = 0; $i < $fields_count; $i++
) {
70 $bgcolor = ($i %
2) ?
$cfgBgcolorOne : $cfgBgcolorTwo;
71 $fieldsize = (($fields_len[$i] > 40) ?
40 : $fields_len[$i]);
73 <tr bgcolor
="<?php echo $bgcolor; ?>">
74 <td
><?php
echo htmlspecialchars($fields_list[$i]); ?
></td
>
75 <td
><?php
echo $fields_type[$i]; ?
></td
>
77 <input type
="text" name
="fields[]" size
="<?php echo $fieldsize; ?>" maxlength
="<?php echo $fields_len[$i]; ?>" />
78 <input type
="hidden" name
="names[]" value
="<?php echo urlencode($fields_list[$i]); ?>" />
79 <input type
="hidden" name
="types[]" value
="<?php echo $fields_type[$i]; ?>" />
89 <?php
echo $strDisplayOrder; ?
><br
/>
90 <select name
="orderField" style
="vertical-align: middle">
91 <option value
="--nil--"></option
>
94 for ($i = 0; $i < mysql_num_fields($result); $i++
) {
95 $field = mysql_field_name($result, $i);
97 echo '<option value="' . urlencode($field) . '">' . htmlspecialchars($field) . '</option>' . "\n";
101 <input type
="radio" name
="order" value
="ASC" checked
="checked" />
102 <?php
echo $strAscending; ?
> 
;
103 <input type
="radio" name
="order" value
="DESC" />
104 <?php
echo $strDescending; ?
><br
/><br
/>
108  
; 
; 
; 
;
109 <input type
="submit" name
="submit" value
="<?php echo $strGo; ?>" />
114 include('./footer.inc.php3');
119 * Selection criteria have been submitted -> do the work
123 $sql_query = 'SELECT ' . backquote(urldecode($param[0]));
128 $sql_query .= ',' . backquote(urldecode($param[$i]));
132 $sql_query .= ' FROM ' . backquote($table);
135 $sql_query .= ' WHERE ' . ((get_magic_quotes_gpc()) ?
stripslashes($where) : $where);
138 $sql_query .= ' WHERE 1';
139 for ($i = 0; $i < count($fields); $i++
) {
140 if (!empty($fields) && $fields[$i] != '') {
142 if ($types[$i] == 'string' ||
$types[$i] == 'blob') {
145 if (!get_magic_quotes_gpc()) {
146 $fields[$i] = str_replace('"', '\\"', $fields[$i]);
149 else if ($types[$i] == 'date' ||
$types[$i] == 'time') {
154 if (strstr($fields[$i], '%')) {
161 if (substr($fields[$i], 0, 1) == '<' ||
substr($fields[$i], 0, 1) == '>') {
165 $sql_query .= ' AND ' . backquote(urldecode($names[$i])) . " $cmp $quot$fields[$i]$quot";
169 if ($orderField != '--nil--') {
170 $sql_query .= ' ORDER BY ' . backquote(urldecode($orderField)) . ' ' . $order;
173 $url_query = 'lang=' . $lang
174 . '&server=' . urlencode($server)
175 . '&db=' . urlencode($db)
176 . '&table=' . urlencode($table)
177 . '&sql_query=' . urlencode($sql_query)
179 . '&sessionMaxRows=' . $sessionMaxRows
180 . '&goto=db_details.php3';
181 header('Location: sql.php3?' . $url_query);