diff --git a/src/html/bar/download.php b/src/html/bar/download.php
new file mode 100644
index 0000000..03fac81
--- /dev/null
+++ b/src/html/bar/download.php
@@ -0,0 +1,75 @@
+
+CSV Data Preview";
+echo "
";
+
+foreach($sql as $query){
+
+ // Match table name from query
+ preg_match('/from\s+(\S+)/i', $query, $matches);
+ $tableName = $matches[1];
+
+ // Create a temporary file
+ $filepath = tempnam(__DIR__ . "/tmp",$tableName . "_csv_");
+ $tmpFile = basename($filepath);
+
+ // Store temporary file path to download later
+ $csvFiles[] = $tmpFile;
+
+ // Open the temporary file for writing
+ $output = fopen($filepath, 'w');
+
+ // Execute query
+ $stmt = $pdo->prepare($query);
+ $stmt->execute();
+ $result = $stmt->fetchAll(PDO::FETCH_ASSOC);
+
+ // Write column headers to the CSV
+ if (!empty($result)) {
+ fputcsv($output, array_keys($result[0]));
+ }
+
+ // Write each row to the CSV
+ foreach ($result as $row) {
+ fputcsv($output, $row);
+ }
+
+ // Close the temporary file
+ fclose($output);
+
+ // Display the CSV content in the browser as a preview
+ echo "Table: $tableName
";
+ echo "
";
+
+ // Open the file for reading and output its contents
+ $csvData = file_get_contents($filepath);
+ echo nl2br($csvData); // Display CSV data
+
+ echo "
";
+
+ // Provide a link to download the file
+ echo 'Download ' . $tableName . ' CSV';
+}
+
+echo "";
+?>
\ No newline at end of file