<?php
include("conf.php");
$tblname = "netzbrett";
$createfile ="mysql.sql";

$phpmyadmin = true;

function dump_entry($entry) {
  $fields = "";
  $values = "";
  foreach($entry as $key=>$val) {
    if ((trim($key) != "") && ($key != 'NEXT')) {
      $fields .= sprintf("%s, ", addslashes($key));
      if ($GLOBALS['phpmyadmin']) { 
        $val = str_replace("')","'\\)",$val);
      }       
      $values .= sprintf("'%s', ", ereg_replace("\r\n|<br>",'\\n',addslashes($val)));
    }
  }
  $fields = ereg_replace(", $","",$fields);
  $values = ereg_replace(", $","",$values);
  return sprintf("INSERT INTO %s (%s) VALUES (%s);\r\n", $GLOBALS["tblname"], $fields, $values);
}

header("Content-type: text/plain"); 

@readfile($createfile);

$entries = read_entries($data_dir);
if (is_array($entries)) {
  foreach($entries as $key=>$val) {
    $entry = read_entry($data_dir,$key);
    if (is_array($entry)) {
      echo dump_entry($entry);
      flush();
    }
  }
}

?>