6 * Set of functions used to display the records returned by a sql query
11 if (!defined('PMA_DISPLAY_TBL_LIB_INCLUDED')){
12 define('PMA_DISPLAY_TBL_LIB_INCLUDED', 1);
15 * Defines the display mode to use for the results of a sql query
17 * It uses a synthetic string that contains all the required informations.
19 * - the first two characters stand for the the action to do while
20 * clicking on the "edit" link (eg 'ur' for update a row, 'nn' for no
22 * - the next two characters stand for the the action to do while
23 * clicking on the "delete" link (eg 'kp' for kill a process, 'nn' for
25 * - the next characters are boolean values (1/0) and respectively stand
26 * for sorting links, navigation bar, "insert a new row" link, the
27 * bookmark feature and the expand/collapse text/blob fields button.
28 * Of course '0'/'1' means the feature won't/will be enabled.
30 * @param string the synthetic value for display_mode (see ยง1 a few
31 * lines above for explanations)
32 * @param integer the total number of rows returned by the sql query
33 * without any programmatically appended "LIMIT" clause
34 * (just a copy of $unlim_num_rows if it exists, else
35 * computed inside this function)
37 * @return array an array with explicit indexes for all the display
40 * @global string the database name
41 * @global string the table name
42 * @global integer the total number of rows returned by the sql query
43 * without any programmatically appended "LIMIT" clause
44 * @global array the properties of the fields returned by the query
45 * @global string the url to return to in case of error in a sql
50 * @see PMA_displayTable()
52 function PMA_setDisplayMode(&$the_disp_mode, &$the_total)
55 global $unlim_num_rows, $fields_meta;
58 // 1. Initializes the $do_display array
59 $do_display = array();
60 $do_display['edit_lnk'] = $the_disp_mode[0] . $the_disp_mode[1];
61 $do_display['del_lnk'] = $the_disp_mode[2] . $the_disp_mode[3];
62 $do_display['sort_lnk'] = (string) $the_disp_mode[4];
63 $do_display['nav_bar'] = (string) $the_disp_mode[5];
64 $do_display['ins_row'] = (string) $the_disp_mode[6];
65 $do_display['bkm_form'] = (string) $the_disp_mode[7];
66 $do_display['text_btn'] = (string) $the_disp_mode[8];
68 // 2. Display mode is not "false for all elements" -> updates the
70 if ($the_disp_mode != 'nnnn00000') {
71 // 2.1 Statement is a "SELECT COUNT",
72 // "CHECK/ANALYZE/REPAIR/OPTIMIZE" or an "EXPLAIN"
73 if ($GLOBALS['is_count'] ||
$GLOBALS['is_maint'] ||
$GLOBALS['is_explain']) {
74 $do_display['edit_lnk'] = 'nn'; // no edit link
75 $do_display['del_lnk'] = 'nn'; // no delete link
76 $do_display['sort_lnk'] = (string) '0';
77 $do_display['nav_bar'] = (string) '0';
78 $do_display['ins_row'] = (string) '0';
79 $do_display['bkm_form'] = (string) '1';
80 $do_display['text_btn'] = (string) '0';
82 // 2.2 Statement is a "SHOW..."
83 else if ($GLOBALS['is_show']) {
84 // 2.2.1 TODO : defines edit/delete links depending on show statement
85 $tmp = eregi('^SHOW[[:space:]]+(VARIABLES|(FULL[[:space:]]+)?PROCESSLIST|STATUS|TABLE|GRANTS|CREATE|LOGS)', $GLOBALS['sql_query'], $which);
86 if (strpos(' ' . strtoupper($which[1]), 'PROCESSLIST') > 0) {
87 $do_display['edit_lnk'] = 'nn'; // no edit link
88 $do_display['del_lnk'] = 'kp'; // "kill process" type edit link
91 // Default case -> no links
92 $do_display['edit_lnk'] = 'nn'; // no edit link
93 $do_display['del_lnk'] = 'nn'; // no delete link
95 // 2.2.2 Other settings
96 $do_display['sort_lnk'] = (string) '0';
97 $do_display['nav_bar'] = (string) '0';
98 $do_display['ins_row'] = (string) '0';
99 $do_display['bkm_form'] = (string) '1';
100 $do_display['text_btn'] = (string) '0';
102 // 2.3 Other statements (ie "SELECT" ones) -> updates
103 // $do_display['edit_lnk'], $do_display['del_lnk'] and
104 // $do_display['text_btn'] (keeps other default values)
106 $prev_table = $fields_meta[0]->table
;
107 for ($i = 0; $i < $GLOBALS['fields_cnt']; $i++
) {
108 $is_link = ($do_display['edit_lnk'] != 'nn'
109 ||
$do_display['del_lnk'] != 'nn'
110 ||
$do_display['sort_lnk'] != '0'
111 ||
$do_display['ins_row'] != '0');
112 // 2.3.1 Displays text cut/expand button?
113 if ($do_display['text_btn'] == '0' && eregi('BLOB', $fields_meta[$i]->type
)) {
114 $do_display['text_btn'] = (string) '1';
119 // 2.3.2 Displays edit/delete/sort/insert links?
121 && ($fields_meta[$i]->table
== '' ||
$fields_meta[$i]->table
!= $prev_table)) {
122 $do_display['edit_lnk'] = 'nn'; // don't display links
123 $do_display['del_lnk'] = 'nn';
124 // TODO: May be problematic with same fields names in
126 // $do_display['sort_lnk'] = (string) '0';
127 $do_display['ins_row'] = (string) '0';
128 if ($do_display['text_btn'] == '1') {
132 $prev_table = $fields_meta[$i]->table
;
134 } // end if..elseif...else (2.1 -> 2.3)
137 // 3. Gets the total number of rows if it is unknown
138 if (isset($unlim_num_rows) && $unlim_num_rows != '') {
139 $the_total = $unlim_num_rows;
141 else if (($do_display['nav_bar'] == '1' ||
$do_display['sort_lnk'] == '1')
142 && (!empty($db) && !empty($table))) {
143 $local_query = 'SELECT COUNT(*) AS total FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table);
144 $result = mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url);
145 $the_total = mysql_result($result, 0, 'total');
146 mysql_free_result($result);
149 // 4. If navigation bar or sorting fields names urls should be
150 // displayed but there is only one row, change these settings to
152 if ($do_display['nav_bar'] == '1' ||
$do_display['sort_lnk'] == '1') {
153 if (isset($unlim_num_rows) && $unlim_num_rows < 2) {
154 $do_display['nav_bar'] = (string) '0';
155 $do_display['sort_lnk'] = (string) '0';
159 // 5. Updates the synthetic var
160 $the_disp_mode = join('', $do_display);
163 } // end of the 'PMA_setDisplayMode()' function
167 * Displays a navigation bar to browse among the results of a sql query
169 * @param integer the offset for the "next" page
170 * @param integer the offset for the "previous" page
171 * @param string the url-encoded query
173 * @global string the current language
174 * @global integer the server to use (refers to the number in the
175 * configuration file)
176 * @global string the database name
177 * @global string the table name
178 * @global string the url to go back in case of errors
179 * @global integer the total number of rows returned by the sql query
180 * @global integer the total number of rows returned by the sql query
181 * without any programmatically appended "LIMIT" clause
182 * @global integer the current position in results
183 * @global mixed the maximum number of rows per page ('all' = no limit)
184 * @global string the display mode (horizontal/vertical)
185 * @global integer the number of row to display between two table headers
186 * @global boolean whether to limit the number of displayed characters of
187 * text type fields or not
191 * @see PMA_displayTable()
193 function PMA_displayTableNavigation($pos_next, $pos_prev, $encoded_query)
195 global $lang, $server, $db, $table;
197 global $num_rows, $unlim_num_rows, $pos, $session_max_rows;
198 global $disp_direction, $repeat_cells;
199 global $dontlimitchars;
202 <!-- Navigation bar
-->
206 // Move to the beginning or to the previous page
207 if ($pos > 0 && $session_max_rows != 'all') {
208 // loic1: patch #474210 from Gosha Sakovich - part 1
209 if ($GLOBALS['cfgNavigationBarIconic']) {
210 $caption1 = '<<';
211 $caption2 = ' < ';
212 $title1 = ' title="' . $GLOBALS['strPos1'] . '"';
213 $title2 = ' title="' . $GLOBALS['strPrevious'] . '"';
215 $caption1 = $GLOBALS['strPos1'] . ' <<';
216 $caption2 = $GLOBALS['strPrevious'] . ' <';
219 } // end if... else...
222 <form action
="sql.php3" method
="post">
223 <input type
="hidden" name
="lang" value
="<?php echo $lang; ?>" />
224 <input type
="hidden" name
="server" value
="<?php echo $server; ?>" />
225 <input type
="hidden" name
="db" value
="<?php echo $db; ?>" />
226 <input type
="hidden" name
="table" value
="<?php echo $table; ?>" />
227 <input type
="hidden" name
="sql_query" value
="<?php echo $encoded_query; ?>" />
228 <input type
="hidden" name
="pos" value
="0" />
229 <input type
="hidden" name
="session_max_rows" value
="<?php echo $session_max_rows; ?>" />
230 <input type
="hidden" name
="disp_direction" value
="<?php echo $disp_direction; ?>" />
231 <input type
="hidden" name
="repeat_cells" value
="<?php echo $repeat_cells; ?>" />
232 <input type
="hidden" name
="goto" value
="<?php echo $goto; ?>" />
233 <input type
="hidden" name
="dontlimitchars" value
="<?php echo $dontlimitchars; ?>" />
234 <input type
="submit" name
="navig" value
="<?php echo $caption1; ?>"<?php
echo $title1; ?
> />
238 <form action
="sql.php3" method
="post">
239 <input type
="hidden" name
="lang" value
="<?php echo $lang; ?>" />
240 <input type
="hidden" name
="server" value
="<?php echo $server; ?>" />
241 <input type
="hidden" name
="db" value
="<?php echo $db; ?>" />
242 <input type
="hidden" name
="table" value
="<?php echo $table; ?>" />
243 <input type
="hidden" name
="sql_query" value
="<?php echo $encoded_query; ?>" />
244 <input type
="hidden" name
="pos" value
="<?php echo $pos_prev; ?>" />
245 <input type
="hidden" name
="session_max_rows" value
="<?php echo $session_max_rows; ?>" />
246 <input type
="hidden" name
="disp_direction" value
="<?php echo $disp_direction; ?>" />
247 <input type
="hidden" name
="repeat_cells" value
="<?php echo $repeat_cells; ?>" />
248 <input type
="hidden" name
="goto" value
="<?php echo $goto; ?>" />
249 <input type
="hidden" name
="dontlimitchars" value
="<?php echo $dontlimitchars; ?>" />
250 <input type
="submit" name
="navig" value
="<?php echo $caption2; ?>"<?php
echo $title2; ?
> />
261 <form action
="sql.php3" method
="post"
262 onsubmit
="return (checkFormElementInRange(this, 'session_max_rows', 1) && checkFormElementInRange(this, 'pos', 0, <?php echo $unlim_num_rows - 1; ?>))">
263 <input type
="hidden" name
="lang" value
="<?php echo $lang; ?>" />
264 <input type
="hidden" name
="server" value
="<?php echo $server; ?>" />
265 <input type
="hidden" name
="db" value
="<?php echo $db; ?>" />
266 <input type
="hidden" name
="table" value
="<?php echo $table; ?>" />
267 <input type
="hidden" name
="sql_query" value
="<?php echo $encoded_query; ?>" />
268 <input type
="hidden" name
="goto" value
="<?php echo $goto; ?>" />
269 <input type
="hidden" name
="dontlimitchars" value
="<?php echo $dontlimitchars; ?>" />
270 <input type
="submit" name
="navig" value
="<?php echo $GLOBALS['strShow']; ?> :" />
271 <input type
="text" name
="session_max_rows" size
="3" value
="<?php echo (($session_max_rows != 'all') ? $session_max_rows : $GLOBALS['cfgMaxRows']); ?>" onfocus
="this.select()" />
272 <?php
echo $GLOBALS['strRowsFrom'] . "\n"; ?
>
273 <input type
="text" name
="pos" size
="3" value
="<?php echo (($pos_next >= $unlim_num_rows) ? 0 : $pos_next); ?>" onfocus
="this.select()" />
276 // Display mode (horizontal/vertical and repeat headers)
277 $param1 = ' <select name="disp_direction">' . "\n"
278 . ' <option value="horizontal"' . (($disp_direction == 'horizontal') ?
' selected="selected"': '') . '>' . $GLOBALS['strRowsModeHorizontal'] . '</option>' . "\n"
279 . ' <option value="vertical"' . (($disp_direction == 'vertical') ?
' selected="selected"': '') . '>' . $GLOBALS['strRowsModeVertical'] . '</option>' . "\n"
280 . ' </select>' . "\n"
282 $param2 = ' <input type="text" size="3" name="repeat_cells" value="' . $repeat_cells . '" />' . "\n"
284 echo ' ' . sprintf($GLOBALS['strRowsModeOptions'], "\n" . $param1, "\n" . $param2) . "\n";
292 // Move to the next page or to the last one
293 if (($pos +
$session_max_rows < $unlim_num_rows) && $num_rows >= $session_max_rows
294 && $session_max_rows != 'all') {
295 // loic1: patch #474210 from Gosha Sakovich - part 2
296 if ($GLOBALS['cfgNavigationBarIconic']) {
297 $caption3 = ' > ';
298 $caption4 = '>>';
299 $title3 = ' title="' . $GLOBALS['strNext'] . '"';
300 $title4 = ' title="' . $GLOBALS['strEnd'] . '"';
302 $caption3 = '> ' . $GLOBALS['strNext'];
303 $caption4 = '>> ' . $GLOBALS['strEnd'];
306 } // end if... else...
310 <form action
="sql.php3" method
="post">
311 <input type
="hidden" name
="lang" value
="<?php echo $lang; ?>" />
312 <input type
="hidden" name
="server" value
="<?php echo $server; ?>" />
313 <input type
="hidden" name
="db" value
="<?php echo $db; ?>" />
314 <input type
="hidden" name
="table" value
="<?php echo $table; ?>" />
315 <input type
="hidden" name
="sql_query" value
="<?php echo $encoded_query; ?>" />
316 <input type
="hidden" name
="pos" value
="<?php echo $pos_next; ?>" />
317 <input type
="hidden" name
="session_max_rows" value
="<?php echo $session_max_rows; ?>" />
318 <input type
="hidden" name
="disp_direction" value
="<?php echo $disp_direction; ?>" />
319 <input type
="hidden" name
="repeat_cells" value
="<?php echo $repeat_cells; ?>" />
320 <input type
="hidden" name
="goto" value
="<?php echo $goto; ?>" />
321 <input type
="hidden" name
="dontlimitchars" value
="<?php echo $dontlimitchars; ?>" />
322 <input type
="submit" name
="navig" value
="<?php echo $caption3; ?>"<?php
echo $title3; ?
> />
326 <form action
="sql.php3" method
="post"
327 onsubmit
="return <?php echo (($pos + $session_max_rows < $unlim_num_rows && $num_rows >= $session_max_rows) ? 'true' : 'false'); ?>">
328 <input type
="hidden" name
="lang" value
="<?php echo $lang; ?>" />
329 <input type
="hidden" name
="server" value
="<?php echo $server; ?>" />
330 <input type
="hidden" name
="db" value
="<?php echo $db; ?>" />
331 <input type
="hidden" name
="table" value
="<?php echo $table; ?>" />
332 <input type
="hidden" name
="sql_query" value
="<?php echo $encoded_query; ?>" />
333 <input type
="hidden" name
="pos" value
="<?php echo $unlim_num_rows - $session_max_rows; ?>" />
334 <input type
="hidden" name
="session_max_rows" value
="<?php echo $session_max_rows; ?>" />
335 <input type
="hidden" name
="disp_direction" value
="<?php echo $disp_direction; ?>" />
336 <input type
="hidden" name
="repeat_cells" value
="<?php echo $repeat_cells; ?>" />
337 <input type
="hidden" name
="goto" value
="<?php echo $goto; ?>" />
338 <input type
="hidden" name
="dontlimitchars" value
="<?php echo $dontlimitchars; ?>" />
339 <input type
="submit" name
="navig" value
="<?php echo $caption4; ?>"<?php
echo $title4; ?
> />
345 // Show all the records if allowed
346 if ($GLOBALS['cfgShowAll'] && ($num_rows < $unlim_num_rows)) {
353 <form action
="sql.php3" method
="post">
354 <input type
="hidden" name
="lang" value
="<?php echo $lang; ?>" />
355 <input type
="hidden" name
="server" value
="<?php echo $server; ?>" />
356 <input type
="hidden" name
="db" value
="<?php echo $db; ?>" />
357 <input type
="hidden" name
="table" value
="<?php echo $table; ?>" />
358 <input type
="hidden" name
="sql_query" value
="<?php echo $encoded_query; ?>" />
359 <input type
="hidden" name
="pos" value
="0" />
360 <input type
="hidden" name
="session_max_rows" value
="all" />
361 <input type
="hidden" name
="disp_direction" value
="<?php echo $disp_direction; ?>" />
362 <input type
="hidden" name
="repeat_cells" value
="<?php echo $repeat_cells; ?>" />
363 <input type
="hidden" name
="goto" value
="<?php echo $goto; ?>" />
364 <input type
="hidden" name
="dontlimitchars" value
="<?php echo $dontlimitchars; ?>" />
365 <input type
="submit" name
="navig" value
="<?php echo $GLOBALS['strShowAll']; ?>" />
376 } // end of the 'PMA_displayTableNavigation()' function
380 * Displays the headers of the results table
382 * @param array which elements to display
383 * @param array the list of fields properties
384 * @param integer the total number of fields returned by the sql query
386 * @return boolean always true
388 * @global string the current language
389 * @global integer the server to use (refers to the number in the
390 * configuration file)
391 * @global string the database name
392 * @global string the table name
393 * @global string the sql query
394 * @global string the url to go back in case of errors
395 * @global integer the total number of rows returned by the sql query
396 * @global integer the current position in results
397 * @global integer the maximum number of rows per page
398 * @global array informations used with vertical display mode
399 * @global string the display mode (horizontal/vertical)
400 * @global integer the number of row to display between two table headers
401 * @global boolean whether to limit the number of displayed characters of
402 * text type fields or not
406 * @see PMA_displayTable()
408 function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0)
410 global $lang, $server, $db, $table;
412 global $sql_query, $num_rows, $pos, $session_max_rows;
413 global $vertical_display, $disp_direction, $repeat_cells;
414 global $dontlimitchars;
416 if ($disp_direction == 'horizontal') {
418 <!-- Results table headers
-->
424 $vertical_display['emptypre'] = 0;
425 $vertical_display['emptyafter'] = 0;
427 // 1. Displays the full/partial text button (part 1)...
428 $colspan = ($is_display['edit_lnk'] != 'nn' && $is_display['del_lnk'] != 'nn')
431 $text_url = 'sql.php3'
433 . '&server=' . $server
434 . '&db=' . urlencode($db)
435 . '&table=' . urlencode($table)
436 . '&sql_query=' . urlencode($sql_query)
438 . '&session_max_rows=' . $session_max_rows
440 . '&disp_direction=' . $disp_direction
441 . '&repeat_cells=' . $repeat_cells
442 . '&goto=' . $goto
443 . '&dontlimitchars=' . (($dontlimitchars) ?
0 : 1);
445 // ... before the result table
446 if (($is_display['edit_lnk'] == 'nn' && $is_display['del_lnk'] == 'nn')
447 && $is_display['text_btn'] == '1') {
448 $vertical_display['emptypre'] = ($is_display['edit_lnk'] != 'nn' && $is_display['del_lnk'] != 'nn') ?
2 : 1;
449 if ($disp_direction == 'horizontal') {
451 <td colspan
="<?php echo $fields_cnt; ?>" align
="center">
452 <a href
="<?php echo $text_url; ?>">
453 <img src
="./images/<?php echo (($dontlimitchars) ? 'partialtext' : 'fulltext'); ?>.png" border
="0" width
="50" height
="20" alt
="<?php echo (($dontlimitchars) ? $GLOBALS['strPartialText'] : $GLOBALS['strFullText']); ?>" /></a
>
461 // ... at the left column of the result table header if possible
463 else if ($GLOBALS['cfgModifyDeleteAtLeft'] && $is_display['text_btn'] == '1') {
465 $vertical_display['emptypre'] = ($is_display['edit_lnk'] != 'nn' && $is_display['del_lnk'] != 'nn') ?
2 : 1;
466 if ($disp_direction == 'horizontal') {
468 <td
<?php
echo $colspan; ?
> align
="center">
469 <a href
="<?php echo $text_url; ?>">
470 <img src
="./images/<?php echo (($dontlimitchars) ? 'partialtext' : 'fulltext'); ?>.png" border
="0" width
="50" height
="20" alt
="<?php echo (($dontlimitchars) ? $GLOBALS['strPartialText'] : $GLOBALS['strFullText']); ?>" /></a
>
475 // ... else if no button, displays empty(ies) col(s) if required
476 else if ($GLOBALS['cfgModifyDeleteAtLeft']
477 && ($is_display['edit_lnk'] != 'nn' ||
$is_display['del_lnk'] != 'nn')) {
479 $vertical_display['emptypre'] = ($is_display['edit_lnk'] != 'nn' && $is_display['del_lnk'] != 'nn') ?
2 : 1;
480 if ($disp_direction == 'horizontal') {
482 <td
<?php
echo $colspan; ?
>></td
>
488 // 2. Displays the fields' name
489 // 2.0 If sorting links should be used, checks if the query is a "JOIN"
490 // statement (see 2.1.3)
491 if ($is_display['sort_lnk'] == '1') {
492 $is_join = eregi('(.*)[[:space:]]+FROM[[:space:]]+.*[[:space:]]+JOIN', $sql_query, $select_stt);
496 for ($i = 0; $i < $fields_cnt; $i++
) {
498 // 2.1 Results can be sorted
499 if ($is_display['sort_lnk'] == '1') {
500 // Defines the url used to append/modify a sorting order
501 // 2.1.1 Checks if an hard coded 'order by' clause exists
502 if (eregi('(.*)( ORDER BY (.*))', $sql_query, $regs1)) {
503 if (eregi('((.*)( ASC| DESC)( |$))(.*)', $regs1[2], $regs2)) {
504 $unsorted_sql_query = trim($regs1[1] . ' ' . $regs2[5]);
505 $sql_order = trim($regs2[1]);
507 else if (eregi('((.*)) (LIMIT (.*)|PROCEDURE (.*)|FOR UPDATE|LOCK IN SHARE MODE)', $regs1[2], $regs3)) {
508 $unsorted_sql_query = trim($regs1[1] . ' ' . $regs3[3]);
509 $sql_order = trim($regs3[1]) . ' ASC';
511 $unsorted_sql_query = trim($regs1[1]);
512 $sql_order = trim($regs1[2]) . ' ASC';
515 $unsorted_sql_query = $sql_query;
517 // 2.1.2 Checks if the current column is used to sort the
519 if (empty($sql_order)) {
522 $is_in_sort = eregi(' (`?)' . str_replace('\\', '\\\\', $fields_meta[$i]->name
) . '(`?)[ ,$]', $sql_order);
524 // 2.1.3 Checks if the table name is required (it's the case
525 // for a query with a "JOIN" statement and if the column
528 && !eregi('([^[:space:],]|`[^`]`)[[:space:]]+(as[[:space:]]+)?' . $fields_meta[$i]->name
, $select_stt[1], $parts)) {
529 $sort_tbl = PMA_backquote($fields_meta[$i]->table
) . '.';
533 // 2.1.4 Do define the sorting url
535 // loic1: patch #455484 ("Smart" order)
536 $cfgOrder = strtoupper($GLOBALS['cfgOrder']);
537 if ($cfgOrder == 'SMART') {
538 $cfgOrder = (eregi('time|date', $fields_meta[$i]->type
)) ?
'DESC' : 'ASC';
540 $sort_order = ' ORDER BY ' . $sort_tbl . PMA_backquote($fields_meta[$i]->name
) . ' ' . $cfgOrder;
543 else if (substr($sql_order, -3) == 'ASC' && $is_in_sort) {
544 $sort_order = ' ORDER BY ' . $sort_tbl . PMA_backquote($fields_meta[$i]->name
) . ' DESC';
545 $order_img = ' <img src="./images/asc_order.gif" border="0" width="7" height="7" alt="ASC" />';
547 else if (substr($sql_order, -4) == 'DESC' && $is_in_sort) {
548 $sort_order = ' ORDER BY ' . $sort_tbl . PMA_backquote($fields_meta[$i]->name
) . ' ASC';
549 $order_img = ' <img src="./images/desc_order.gif" border="0" width="7" height="7" alt="DESC" />';
551 if (eregi('(.*)( LIMIT (.*)| PROCEDURE (.*)| FOR UPDATE| LOCK IN SHARE MODE)', $unsorted_sql_query, $regs3)) {
552 $sorted_sql_query = $regs3[1] . $sort_order . $regs3[2];
554 $sorted_sql_query = $unsorted_sql_query . $sort_order;
556 $url_query = 'lang=' . $lang
557 . '&server=' . $server
558 . '&db=' . urlencode($db)
559 . '&table=' . urlencode($table)
561 . '&session_max_rows=' . $session_max_rows
562 . '&disp_direction=' . $disp_direction
563 . '&repeat_cells=' . $repeat_cells
564 . '&dontlimitchars=' . $dontlimitchars
565 . '&sql_query=' . urlencode($sorted_sql_query);
567 // 2.1.5 Displays the sorting url
568 if ($disp_direction == 'horizontal') {
571 <a href
="sql.php3?<?php echo $url_query; ?>">
572 <?php
echo htmlspecialchars($fields_meta[$i]->name
); ?
></a
><?php
echo $order_img . "\n"; ?
>
576 $vertical_display['desc'][] = ' <th>' . "\n"
577 . ' <a href="sql.php3?' . $url_query . '">' . "\n"
578 . ' ' . htmlspecialchars($fields_meta[$i]->name
) . '</a>' . $order_img . "\n"
582 // 2.2 Results can't be sorted
585 if ($disp_direction == 'horizontal') {
588 <?php
echo htmlspecialchars($fields_meta[$i]->name
) . "\n"; ?
>
592 $vertical_display['desc'][] = ' <th>' . "\n"
593 . ' ' . htmlspecialchars($fields_meta[$i]->name
) . "\n"
599 // 3. Displays the full/partial text button (part 2) at the right
600 // column of the result table header if possible and required...
601 if ($GLOBALS['cfgModifyDeleteAtRight']
602 && ($is_display['edit_lnk'] != 'nn' ||
$is_display['del_lnk'] != 'nn')
603 && $is_display['text_btn'] == '1') {
605 $vertical_display['emptyafter'] = ($is_display['edit_lnk'] != 'nn' && $is_display['del_lnk'] != 'nn') ?
2 : 1;
606 if ($disp_direction == 'horizontal') {
608 <td
<?php
echo $colspan; ?
> align
="center">
609 <a href
="<?php echo $text_url; ?>">
610 <img src
="./images/<?php echo (($dontlimitchars) ? 'partialtext' : 'fulltext'); ?>.png" border
="0" width
="50" height
="20" alt
="<?php echo (($dontlimitchars) ? $GLOBALS['strPartialText'] : $GLOBALS['strFullText']); ?>" /></a
>
615 // ... else if no button, displays empty cols if required
616 else if ($GLOBALS['cfgModifyDeleteAtRight']
617 && ($is_display['edit_lnk'] == 'nn' && $is_display['del_lnk'] == 'nn')) {
618 echo "\n" . ' <td' . $colspan . '></td>';
619 $vertical_display['emptyafter'] = ($is_display['edit_lnk'] != 'nn' && $is_display['del_lnk'] != 'nn') ?
2 : 1;
623 if ($disp_direction == 'horizontal') {
631 } // end of the 'PMA_displayTableHeaders()' function
635 * Displays the body of the results table
637 * @param integer the link id associated to the query which results have
639 * @param array which elements to display
640 * @param array the list of relations
642 * @return boolean always true
644 * @global string the current language
645 * @global integer the server to use (refers to the number in the
646 * configuration file)
647 * @global string the database name
648 * @global string the table name
649 * @global string the sql query
650 * @global string the url to go back in case of errors
651 * @global integer the current position in results
652 * @global integer the maximum number of rows per page
653 * @global array the list of fields properties
654 * @global integer the total number of fields returned by the sql query
655 * @global array informations used with vertical display mode
656 * @global string the display mode (horizontal/vertical)
657 * @global integer the number of row to display between two table headers
658 * @global boolean whether to limit the number of displayed characters of
659 * text type fields or not
663 * @see PMA_displayTable()
665 function PMA_displayTableBody(&$dt_result, &$is_display, $map = array())
667 global $lang, $server, $db, $table;
669 global $sql_query, $pos, $session_max_rows, $fields_meta, $fields_cnt;
670 global $vertical_display, $disp_direction, $repeat_cells;
671 global $dontlimitchars;
674 <!-- Results table body
-->
679 $vertical_display['edit'] = array();
680 $vertical_display['delete'] = array();
681 $vertical_display['data'] = array();
683 // Correction uva 19991216 in the while below
684 // Previous code assumed that all tables have keys, specifically that
685 // the phpMyAdmin GUI should support row delete/edit only for such
687 // Although always using keys is arguably the prescribed way of
688 // defining a relational table, it is not required. This will in
689 // particular be violated by the novice.
690 // We want to encourage phpMyAdmin usage by such novices. So the code
691 // below has been changed to conditionally work as before when the
692 // table being displayed has one or more keys; but to display
693 // delete/edit options correctly for tables without keys.
695 // loic1: use 'mysql_fetch_array' rather than 'mysql_fetch_row' to get
698 while ($row = mysql_fetch_array($dt_result)) {
700 // lem9: "vertical display" mode stuff
701 if (($foo != 0) && ($repeat_cells != 0) && !($foo %
$repeat_cells) && $disp_direction == 'horizontal') {
704 for ($foo_i = 0; $foo_i < $vertical_display['emptypre']; $foo_i++
) {
705 echo ' <td> </td>' . "\n";
708 reset($vertical_display['desc']);
709 while (list($key, $val) = each($vertical_display['desc'])) {
713 for ($foo_i = 0; $foo_i < $vertical_display['emptyafter']; $foo_i++
) {
714 echo ' <td> </td>' . "\n";
720 $bgcolor = ($foo %
2) ?
$GLOBALS['cfgBgcolorOne'] : $GLOBALS['cfgBgcolorTwo'];
722 if ($disp_direction == 'horizontal') {
723 // loic1: pointer code part
724 if ($GLOBALS['cfgBrowsePointerColor'] == '') {
726 } else if ($GLOBALS['cfgBrowseMarkRow'] == '1') {
727 $on_mouse = ' onmousedown="setPointer(this, \'' . $GLOBALS['cfgBrowsePointerColor'] . '\', \'' . $bgcolor . '\')"';
729 $on_mouse = ' onmouseover="setPointer(this, \'' . $GLOBALS['cfgBrowsePointerColor'] . '\', \'' . $bgcolor . '\')" onmouseout="setPointer(this, \'' . $bgcolor . '\', \'' . $bgcolor . '\')"';
732 <tr
<?php
echo $on_mouse; ?
>>
735 echo (($disp_direction == 'horizontal') ?
"\n" : '');
737 // 1. Prepares the row (gets primary keys to use)
738 if ($is_display['edit_lnk'] != 'nn' ||
$is_display['del_lnk'] != 'nn') {
741 $uva_nonprimary_condition = '';
743 // 1.1 Results from a "SELECT" statement -> builds the
744 // the "primary" key to use in links
745 if ($is_display['edit_lnk'] == 'ur' /* || $is_display['edit_lnk'] == 'dr' */) {
746 for ($i = 0; $i < $fields_cnt; ++
$i) {
747 $primary = $fields_meta[$i];
748 $condition = ' ' . PMA_backquote($primary->name
) . ' ';
749 if (!isset($row[$primary->name
])
750 ||
(function_exists('is_null') && is_null($row[$primary->name
]))) {
751 $condition .= 'IS NULL AND';
753 $condition .= '= \'' . PMA_sqlAddslashes($row[$primary->name
]) . '\' AND';
755 if ($primary->primary_key
> 0) {
756 $primary_key .= $condition;
757 } else if ($primary->unique_key
> 0) {
758 $unique_key .= $condition;
760 $uva_nonprimary_condition .= $condition;
763 // Correction uva 19991216: prefer primary or unique keys
764 // for condition, but use conjunction of all values if no
767 $uva_condition = $primary_key;
768 } else if ($unique_key) {
769 $uva_condition = $unique_key;
771 $uva_condition = $uva_nonprimary_condition;
773 $uva_condition = urlencode(ereg_replace(' ?AND$', '', $uva_condition));
776 // 1.2 Defines the urls for the modify/delete link(s)
777 $url_query = 'lang=' . $lang
778 . '&server=' . $server
779 . '&db=' . urlencode($db)
780 . '&table=' . urlencode($table)
782 . '&session_max_rows=' . $session_max_rows
783 . '&disp_direction=' . $disp_direction
784 . '&repeat_cells=' . $repeat_cells
785 . '&dontlimitchars=' . $dontlimitchars;
787 // 1.2.1 Modify link(s)
788 if ($is_display['edit_lnk'] == 'ur') { // update row case
790 && empty($GLOBALS['QUERY_STRING'])
791 && (empty($GLOBALS['HTTP_SERVER_VARS']) ||
empty($GLOBALS['HTTP_SERVER_VARS']['QUERY_STRING']))) {
794 $lnk_goto = 'sql.php3';
796 $edit_url = 'tbl_change.php3'
798 . '&primary_key=' . $uva_condition
799 . '&sql_query=' . urlencode($sql_query)
800 . '&goto=' . urlencode($lnk_goto);
801 $edit_str = $GLOBALS['strEdit'];
804 // 1.2.2 Delete/Kill link(s)
805 if ($is_display['del_lnk'] == 'dr') { // delete row case
806 $lnk_goto = 'sql.php3'
807 . '?' . str_replace('&', '&', $url_query)
808 . '&sql_query=' . urlencode($sql_query)
809 . '&zero_rows=' . urlencode(htmlspecialchars($GLOBALS['strDeleted']))
810 . '&goto=tbl_properties.php3';
811 $del_url = 'sql.php3'
813 . '&sql_query=' . urlencode('DELETE FROM ' . PMA_backquote($table) . ' WHERE') . $uva_condition . urlencode(' LIMIT 1')
814 . '&zero_rows=' . urlencode(htmlspecialchars($GLOBALS['strDeleted']))
815 . '&goto=' . urlencode($lnk_goto);
816 $js_conf = 'DELETE FROM ' . PMA_jsFormat($table)
817 . ' WHERE ' . trim(PMA_jsFormat(urldecode($uva_condition), FALSE)) . ' LIMIT 1';
818 $del_str = $GLOBALS['strDelete'];
819 } else if ($is_display['del_lnk'] == 'kp') { // kill process case
820 $lnk_goto = 'sql.php3'
821 . '?' . str_replace('&', '&', $url_query)
822 . '&sql_query=' . urlencode($sql_query)
824 $del_url = 'sql.php3'
826 . '&server=' . $server
828 . '&sql_query=' . urlencode('KILL ' . $row['Id'])
829 . '&goto=' . urlencode($lnk_goto);
830 $js_conf = 'KILL ' . $row['Id'];
831 $del_str = $GLOBALS['strKill'];
834 // 1.3 Displays the links at left if required
835 if ($GLOBALS['cfgModifyDeleteAtLeft']
836 && ($disp_direction == 'horizontal')) {
837 if (!empty($edit_url)) {
839 <td bgcolor
="<?php echo $bgcolor; ?>">
840 <a href
="<?php echo $edit_url; ?>">
841 <?php
echo $edit_str; ?
></a
>
845 if (!empty($del_url)) {
848 <td bgcolor
="<?php echo $bgcolor; ?>">
849 <a href
="<?php echo $del_url; ?>"
850 <?php
if (isset($js_conf)) echo 'onclick="return confirmLink(this, \'' . $js_conf . '\')"'; ?
>>
851 <?php
echo $del_str; ?
></a
>
856 echo (($disp_direction == 'horizontal') ?
"\n" : '');
859 // 2. Displays the rows' values
860 for ($i = 0; $i < $fields_cnt; ++
$i) {
861 $primary = $fields_meta[$i];
862 if ($primary->numeric == 1) {
863 if (!isset($row[$primary->name
])
864 ||
(function_exists('is_null') && is_null($row[$primary->name
]))) {
865 $vertical_display['data'][$foo][$i] = ' <td align="right" valign="top" bgcolor="' . $bgcolor . '"><i>NULL</i></td>' . "\n";
866 } else if ($row[$i] != '') {
867 $vertical_display['data'][$foo][$i] = ' <td align="right" valign="top" bgcolor="' . $bgcolor . '">';
868 if (isset($map[$primary->name
])) {
869 $vertical_display['data'][$foo][$i] .= '<a href="sql.php3?'
870 . 'lang=' . $lang . '&server=' . $server
871 . '&db=' . urlencode($db) . '&table=' . urlencode($map[$primary->name
][0])
872 . '&pos=0&sessionMaxRow=' . $sessionMaxRow . '&dontlimitchars=' . $dontlimitchars
873 . '&sql_query=' . urlencode('SELECT * FROM ' . PMA_backquote($map[$primary->name
][0]) . ' WHERE ' . $map[$primary->name
][1] . ' = ' . $row[$i]) . '">'
874 . $row[$primary->name
] . '</a>';
876 $vertical_display['data'][$foo][$i] .= $row[$primary->name
];
878 $vertical_display['data'][$foo][$i] .= '</td>' . "\n";
880 $vertical_display['data'][$foo][$i] = ' <td align="right" valign="top" bgcolor="' . $bgcolor . '"> </td>' . "\n";
882 } else if ($GLOBALS['cfgShowBlob'] == FALSE && eregi('BLOB', $primary->type
)) {
883 // loic1 : mysql_fetch_fields returns BLOB in place of TEXT
884 // fields type, however TEXT fields must be displayed even
885 // if $cfgShowBlob is false -> get the true type of the
887 $field_flags = mysql_field_flags($dt_result, $i);
888 if (eregi('BINARY', $field_flags)) {
889 $vertical_display['data'][$foo][$i] = ' <td align="center" valign="top" bgcolor="' . $bgcolor . '">[BLOB]</td>' . "\n";
891 if (!isset($row[$primary->name
])
892 ||
(function_exists('is_null') && is_null($row[$primary->name
]))) {
893 $vertical_display['data'][$foo][$i] = ' <td valign="top" bgcolor="' . $bgcolor . '"><i>NULL</i></td>' . "\n";
894 } else if ($row[$primary->name
] != '') {
895 if (strlen($row[$primary->name
]) > $GLOBALS['cfgLimitChars'] && ($dontlimitchars != 1)) {
896 $row[$primary->name
] = substr($row[$primary->name
], 0, $GLOBALS['cfgLimitChars']) . '...';
898 // loic1: displays all space characters, 4 space
899 // characters for tabulations and <cr>/<lf>
900 $row[$primary->name
] = htmlspecialchars($row[$primary->name
]);
901 $row[$primary->name
] = str_replace("\011", ' ', str_replace(' ', ' ', $row[$primary->name
]));
902 $row[$primary->name
] = ereg_replace("((\015\012)|(\015)|(\012))", '<br />', $row[$primary->name
]);
903 $vertical_display['data'][$foo][$i] = ' <td valign="top" bgcolor="' . $bgcolor . '">' . $row[$primary->name
] . '</td>' . "\n";
905 $vertical_display['data'][$foo][$i] = ' <td valign="top" bgcolor="' . $bgcolor . '"> </td>' . "\n";
909 if (!isset($row[$primary->name
])
910 ||
(function_exists('is_null') && is_null($row[$primary->name
]))) {
911 $vertical_display['data'][$foo][$i] = ' <td valign="top" bgcolor="' . $bgcolor . '"><i>NULL</i></td>' . "\n";
912 } else if ($row[$primary->name
] != '') {
913 // loic1: Cut text/blob fields even if $cfgShowBlob is true
914 if (eregi('BLOB', $primary->type
)) {
915 if (strlen($row[$primary->name
]) > $GLOBALS['cfgLimitChars'] && ($dontlimitchars != 1)) {
916 $row[$primary->name
] = substr($row[$primary->name
], 0, $GLOBALS['cfgLimitChars']) . '...';
919 // loic1: displays special characters from binaries
920 $field_flags = mysql_field_flags($dt_result, $i);
921 if (eregi('BINARY', $field_flags)) {
922 $row[$primary->name
] = str_replace("\x00", '\0', $row[$primary->name
]);
923 $row[$primary->name
] = str_replace("\x08", '\b', $row[$primary->name
]);
924 $row[$primary->name
] = str_replace("\x0a", '\n', $row[$primary->name
]);
925 $row[$primary->name
] = str_replace("\x0d", '\r', $row[$primary->name
]);
926 $row[$primary->name
] = str_replace("\x1a", '\Z', $row[$primary->name
]);
928 // loic1: displays all space characters, 4 space
929 // characters for tabulations and <cr>/<lf>
931 $row[$primary->name
] = htmlspecialchars($row[$primary->name
]);
932 $row[$primary->name
] = str_replace("\011", ' ', str_replace(' ', ' ', $row[$primary->name
]));
933 $row[$primary->name
] = ereg_replace("((\015\012)|(\015)|(\012))", '<br />', $row[$primary->name
]);
935 $vertical_display['data'][$foo][$i] = ' <td valign="top" bgcolor="' . $bgcolor . '">' . $row[$primary->name
] . '</td>' . "\n";
937 $vertical_display['data'][$foo][$i] = ' <td valign="top" bgcolor="' . $bgcolor . '"> </td>' . "\n";
941 // lem9: output stored cell
942 if ($disp_direction == 'horizontal') {
943 echo $vertical_display['data'][$foo][$i];
946 if (isset($vertical_display['rowdata'][$i][$foo])) {
947 $vertical_display['rowdata'][$i][$foo] .= $vertical_display['data'][$foo][$i];
949 $vertical_display['rowdata'][$i][$foo] = $vertical_display['data'][$foo][$i];
953 // 3. Displays the modify/delete links on the right if required
954 if ($GLOBALS['cfgModifyDeleteAtRight']
955 && ($disp_direction == 'horizontal')) {
956 if (!empty($edit_url)) {
958 <td bgcolor
="<?php echo $bgcolor; ?>">
959 <a href
="<?php echo $edit_url; ?>">
960 <?php
echo $edit_str; ?
></a
>
964 if (!empty($del_url)) {
967 <td bgcolor
="<?php echo $bgcolor; ?>">
968 <a href
="<?php echo $del_url; ?>"
969 <?php
if (isset($js_conf)) echo 'onclick="return confirmLink(this, \'' . $js_conf . '\')"'; ?
>>
970 <?php
echo $del_str; ?
></a
>
976 if ($disp_direction == 'horizontal') {
983 // 4. Gather links of del_urls and edit_urls in an array for later
985 if (!isset($vertical_display['edit'][$foo])) {
986 $vertical_display['edit'][$foo] = '';
987 $vertical_display['delete'][$foo] = '';
989 if (isset($edit_url)) {
990 $vertical_display['edit'][$foo] .= ' <td bgcolor="' . $bgcolor . '">' . "\n"
991 . ' <a href="' . $edit_url . '">' . "\n"
992 . ' ' . $edit_str . '</a>' . "\n"
996 if (isset($del_url)) {
997 $vertical_display['delete'][$foo] .= ' <td bgcolor="' . $bgcolor . '">' . "\n"
998 . ' <a href="' . $del_url . '"';
1000 if (isset($js_conf)) {
1001 $vertical_display['delete'][$foo] .= 'onclick="return confirmLink(this, \'' . $js_conf . '\')"';
1003 if (isset($del_str)) {
1004 $vertical_display['delete'][$foo] .= '>' . "\n"
1005 . ' ' . $del_str . '</a>' . "\n"
1009 echo (($disp_direction == 'horizontal') ?
"\n" : '');
1014 } // end of the 'PMA_displayTableBody()' function
1018 * Do display the result table with the vertical direction mode.
1019 * Credits for this feature goes to Garvin Hicking <hicking@faktor-e.de>.
1021 * @return boolean always true
1023 * @global array the information to display
1024 * @global integer the number of row to display between two table headers
1028 * @see PMA_displayTable()
1030 function PMA_displayVerticalTable()
1032 global $vertical_display, $repeat_cells;
1034 reset($vertical_display);
1036 // Displays "edit" link at top if required
1037 if ($GLOBALS['cfgModifyDeleteAtLeft'] && is_array($vertical_display['edit'])) {
1039 echo ' <td> </td>' . "\n";
1040 reset($vertical_display['edit']);
1042 while (list($key, $val) = each($vertical_display['edit'])) {
1043 if (($foo_counter != 0) && ($repeat_cells != 0) && !($foo_counter %
$repeat_cells)) {
1044 echo ' <td> </td>' . "\n";
1050 echo '</tr>' . "\n";
1053 // Displays "delete" link at top if required
1054 if ($GLOBALS['cfgModifyDeleteAtLeft'] && is_array($vertical_display['delete'])) {
1056 echo '<td> </td>' . "\n";
1057 reset($vertical_display['delete']);
1059 while (list($key, $val) = each($vertical_display['delete'])) {
1060 if (($foo_counter != 0) && ($repeat_cells != 0) && !($foo_counter %
$repeat_cells)) {
1061 echo '<td> </td>' . "\n";
1067 echo '</tr>' . "\n";
1071 reset($vertical_display['desc']);
1072 while (list($key, $val) = each($vertical_display['desc'])) {
1077 while (list($subkey, $subval) = each($vertical_display['rowdata'][$key])) {
1078 if (($foo_counter != 0) && ($repeat_cells != 0) and !($foo_counter %
$repeat_cells)) {
1086 echo '</tr>' . "\n";
1089 // Displays "edit" link at bottom if required
1090 if ($GLOBALS['cfgModifyDeleteAtRight'] && is_array($vertical_display['edit'])) {
1092 echo ' <td> </td>' . "\n";
1093 reset($vertical_display['edit']);
1095 while (list($key, $val) = each($vertical_display['edit'])) {
1096 if (($foo_counter != 0) && ($repeat_cells != 0) && !($foo_counter %
$repeat_cells)) {
1097 echo '<td> </td>' . "\n";
1103 echo '</tr>' . "\n";
1106 // Displays "delete" link at bottom if required
1107 if ($GLOBALS['cfgModifyDeleteAtRight'] && is_array($vertical_display['delete'])) {
1109 echo '<td> </td>' . "\n";
1110 reset($vertical_display['delete']);
1112 while (list($key, $val) = each($vertical_display['delete'])) {
1113 if (($foo_counter != 0) && ($repeat_cells != 0) && !($foo_counter %
$repeat_cells)) {
1114 echo '<td> </td>' . "\n";
1120 echo '</tr>' . "\n";
1124 } // end of the 'PMA_displayVerticalTable' function
1128 * Displays a table of results returned by a sql query.
1129 * This function is called by the "sql.php3" script.
1131 * @param integer the link id associated to the query which results have
1133 * @param array the display mode
1135 * @global string the current language
1136 * @global integer the server to use (refers to the number in the
1137 * configuration file)
1138 * @global array the current server config
1139 * @global string the database name
1140 * @global string the table name
1141 * @global string the url to go back in case of errors
1142 * @global string the current sql query
1143 * @global integer the total number of rows returned by the sql query
1144 * @global integer the total number of rows returned by the sql query
1145 * without any programmatically appended "LIMIT" clause
1146 * @global integer the current postion of the first record to be
1148 * @global array the list of fields properties
1149 * @global integer the total number of fields returned by the sql query
1150 * @global array informations used with vertical display mode
1151 * @global string the display mode (horizontal/vertical)
1152 * @global integer the number of row to display between two table headers
1153 * @global boolean whether to limit the number of displayed characters of
1154 * text type fields or not
1158 * @see PMA_showMessage(), PMA_setDisplayMode(),
1159 * PMA_displayTableNavigation(), PMA_displayTableHeaders(),
1160 * PMA_displayTableBody()
1162 function PMA_displayTable(&$dt_result, &$the_disp_mode)
1164 global $lang, $server, $cfgServer, $db, $table;
1166 global $sql_query, $num_rows, $unlim_num_rows, $pos, $fields_meta, $fields_cnt;
1167 global $vertical_display, $disp_direction, $repeat_cells;
1168 global $dontlimitchars;
1170 // 1. ----- Prepares the work -----
1172 // 1.1 Gets the informations about which functionnalities should be
1175 $is_display = PMA_setDisplayMode($the_disp_mode, $total);
1180 // 1.2 Defines offsets for the next and previous pages
1181 if ($is_display['nav_bar'] == '1') {
1185 if ($GLOBALS['session_max_rows'] == 'all') {
1189 $pos_next = $pos +
$GLOBALS['cfgMaxRows'];
1190 $pos_prev = $pos - $GLOBALS['cfgMaxRows'];
1191 if ($pos_prev < 0) {
1197 // 1.3 Urlencodes the query to use in input form fields ($sql_query
1198 // will be stripslashed in 'sql.php3' if the 'magic_quotes_gpc'
1199 // directive is set to 'on')
1200 if (get_magic_quotes_gpc()) {
1201 $encoded_sql_query = urlencode(addslashes($sql_query));
1203 $encoded_sql_query = urlencode($sql_query);
1206 // 2. ----- Displays the top of the page -----
1208 // 2.1 Displays a messages with position informations
1209 if ($is_display['nav_bar'] == '1' && isset($pos_next)) {
1210 if (isset($unlim_num_rows) && $unlim_num_rows != $total) {
1211 $selectstring = ', ' . $unlim_num_rows . ' ' . $GLOBALS['strSelectNumRows'];
1215 $last_shown_rec = ($GLOBALS['session_max_rows'] == 'all' ||
$pos_next > $total)
1218 PMA_showMessage($GLOBALS['strShowingRecords'] . " $pos - $last_shown_rec ($total " . $GLOBALS['strTotal'] . $selectstring . ')');
1220 PMA_showMessage($GLOBALS['strSQLQuery']);
1223 // 2.3 Displays the navigation bars
1224 if (!isset($table) ||
strlen(trim($table)) == 0) {
1225 $table = $fields_meta[0]->table
;
1227 if ($is_display['nav_bar'] == '1') {
1228 PMA_displayTableNavigation($pos_next, $pos_prev, $encoded_sql_query);
1231 echo "\n" . '<br /><br />' . "\n";
1234 // 2b ----- Get field references from Database -----
1235 // (see the 'relation' config variable)
1236 // (currently not available for PHP3 due to spliti() )
1241 if (PMA_PHP_INT_VERSION
>= 40000
1242 && isset($cfgServer['relation'])
1243 && !empty($cfgServer['relation'])) {
1245 $tabs = '(\'' . join('\',\'', spliti('`? *((on [^,]+)?,|(NATURAL )?(inner|left|right)( outer)? join) *`?',
1246 eregi_replace('^.*FROM +`?|`? *(on [^,]+)?(WHERE.*)?$', '', $sql_query))) . '\')';
1248 $local_query = 'SELECT src_column, dest_table, dest_column'
1249 . ' FROM ' . $cfgServer['relation']
1250 . ' WHERE src_table IN ' . $tabs;
1251 $result = @mysql_query
($local_query);
1253 while ($rel = mysql_fetch_row($result)) {
1254 $map[$rel[0]] = array($rel[1], $rel[2]);
1259 // 3. ----- Displays the results table -----
1261 <!-- Results table
-->
1262 <table border
="<?php echo $GLOBALS['cfgBorder']; ?>" cellpadding
="5">
1265 PMA_displayTableHeaders($is_display, $fields_meta, $fields_cnt);
1266 PMA_displayTableBody($dt_result, $is_display, $map);
1267 // lem9: vertical output case
1268 if ($disp_direction == 'vertical') {
1269 PMA_displayVerticalTable();
1271 unset($vertical_display);
1279 // 4. ----- Displays the navigation bar at the bottom if required -----
1281 if ($is_display['nav_bar'] == '1') {
1282 PMA_displayTableNavigation($pos_next, $pos_prev, $encoded_sql_query);
1284 echo "\n" . '<br />' . "\n";
1286 } // end of the 'PMA_displayTable()' function
1288 } // $__PMA_DISPLAY_TBL_LIB__