p('</p>'); $sql_query = isset($P['sql_query']) ? $P['sql_query'] : ''; if ($tablename && !$sql_query) { $sql_query = "SELECT * FROM {$tablename} LIMIT 0, 30"; } if ($tablename && $doing == 'structure') { $sql_query = "SHOW FULL COLUMNS FROM {$tablename};\n"; $sql_query .= "SHOW INDEX FROM {$tablename};"; } p('<p><table width="200" border="0" cellpadding="0" cellspacing="0"><tr><td colspan="2">Run SQL query/queries on database ' . $dbname . ':</td></tr><tr><td><textarea name="sql_query" class="area" style="width:600px;height:50px;overflow:auto;">' . htmlspecialchars($sql_query, ENT_QUOTES) . '</textarea></td><td style="padding:0 5px;"><input class="bt" onclick="$(\'doing\').value=\'\'" style="height:50px;" type="submit" value="Query" /></td></tr></table></p>'); if ($sql_query) { $querys = @explode(';', $sql_query); foreach ($querys as $num => $query) { if ($query) { p("<p class=\"red b\">Query#{$num} : " . htmlspecialchars($query, ENT_QUOTES) . "</p>"); switch ($DB->query_res($query)) { case 0: p('<h2>' . $DB->halt('Error') . '</h2>'); break; case 1: $result = $DB->query($query); $tatol = $DB->num_rows($result); p('<table border="0" cellpadding="3" cellspacing="0">'); p('<tr class="head">'); $fieldnum = @mysql_num_fields($result); for ($i = 0; $i < $fieldnum; $i++) { p('<td nowrap>' . @mysql_field_name($result, $i) . '</td>'); } p('</tr>'); if (!$tatol) { p('<tr class="alt2" onmouseover="this.className=\'focus\';" onmouseout="this.className=\'alt2\';"><td nowrap colspan="' . $fieldnum . '" class="red b">No records</td></tr>');