\n");
printf("\n");
}
function PrintPage($html, $host, $user, $pw, $db)
{
$db_id = mysql_connect($host, $user, $pw);
if ($db_id==FALSE)
{
printf("mysql_connect returned the following error: %s\n", mysql_error());
die("");
}
mysql_select_db($db);
$query0 = "SELECT fRunBookDate AS Date, fRunBookText AS Entry ";
$query0 .= "FROM " . $db . ".RunBook ";
$query0 .= "WHERE fRunBookDate REGEXP '^" . $_GET["fDate"] . "' ";
if (!empty($_GET["fRegexp"]))
$query0 .= "AND fRunBookText REGEXP '" . $_GET["fRegexp"] . "' ";
if (!empty($_GET["fNight"]))
$query0 .= "AND fRunBookDate < '" . $_GET["fNight"] . " 13:00:00' AND fRunBookDate > ADDDATE( '" . $_GET["fNight"] . " 13:00:00', INTERVAL -1 DAY) ";
$query0 .= "ORDER BY fRunBookDate";
$result0 = mysql_query($query0, $db_id);
if ($result0)
{
if ($html=="1" || $html=="2")
{
$alias = array
(
"fRunBookDate" => "Date",
"fRunBookText" => "Entry"
);
$rightalign = array
(
);
PrintMagicTable($result0, $alias, $rightalign, "", "", "", "", $_GET);
}
else
PrintText($result0);
mysql_free_result($result0);
}
mysql_close($db_id);
PrintSubmittedQuery($query0, $html, $db, "old");
}
include ("include.php");
include ("db.php");
ini_set("display_errors", "On");
ini_set("mysql.trace_mode", "On");
if (!empty($_GET["fSendTxt"]))
{
header("Content-type: application/octet");
header("Content-Disposition: attachment; filename=query-result.txt");
PrintPage("0", $host, $user, $pw, $db);
}
else
{
if (empty($_GET["fPrintTable"]))
echo (file_get_contents("index-header.html"));
$environment = sizeof($_GET);
if (empty($_GET["fPrintTable"]))
PrintForm($_GET);
if ($environment==0)
printf("No query submitted yet. ");
else
{
if (empty($_GET["fPrintTable"]))
PrintPage("1", $host, $user, $pw, $db);
else
PrintPage("2", $host, $user, $pw, $db);
}
if (empty($_GET["fPrintTable"]))
echo (file_get_contents("index-footer.html"));
}
ini_set("display_errors", "Off");
ini_set("mysql.trace_mode", "Off");
}
?>
|