include "database.php"; include "config.php"; // Get the GET parameters $password_tables = $_GET["password"]; $table = $_GET["table"]; // Check event id if (isset($password_tables) && isset($table)) { if ($password_tables == "albertalias") { // Connect to the database mysql_connect($mysqlserver, $username, $password); $database_select = mysql_select_db($database); // Real escape strings $table = mysql_real_escape_string($table); $query = "SELECT * FROM {$table}"; $query_result = mysql_query($query); $fields_num = MYSQL_NUM_FIELDS($query_result); echo "<table border='1'><tr>"; // printing table headers for ($i = 0; $i < $fields_num; $i++) { $field = MYSQL_FETCH_FIELD($query_result); echo "<td>{$field->name}</td>"; } echo "</tr>\n"; // printing table rows while ($row = MYSQL_FETCH_ROW($query_result)) { echo "<tr>"; // $row is array... foreach( .. ) puts every element // of $row to $cell variable foreach ($row as $cell) { echo "<td>{$cell}</td>"; }
} $schema_insert = STR_REPLACE($sep . "\$", "", $schema_insert); $schema_insert .= "\t"; print TRIM($schema_insert); //end of each mysql row //creates line to separate data from each MySQL table row print "\n----------------------------------------------------\n"; } } else { /* FORMATTING FOR EXCEL DOCUMENTS ('.xls') */ //create title with timestamp: //define separator (defines columns in excel & tabs in word) $sep = "\t"; //tabbed character //start of printing column names as names of MySQL fields for ($i = 0; $i < MYSQL_NUM_FIELDS($result); $i++) { echo MYSQL_FIELD_NAME($result, $i) . "\t"; } print "\n"; //end of printing column names //start while loop to get data while ($row = MYSQL_FETCH_ROW($result)) { //set_time_limit(60); // HaRa $schema_insert = ""; for ($j = 0; $j < mysql_num_fields($result); $j++) { if (!isset($row[$j])) { $schema_insert .= "NULL" . $sep; } elseif ($row[$j] != "") { $schema_insert .= "{$row[$j]}" . $sep; } else { $schema_insert .= "" . $sep;