<?php
session_start();
$user_ID=$_SESSION[user_ID];
if (!$user_ID || $user_ID=='0')
{
header('location: index.php');
die('Login failed');
}
require("util.php");
$sql = new MySQL_class;
$sql->Create("generator");
$esql = new MySQL_class;
$esql->Create("generator");
if ($_GET[project]) { $_SESSION[var_project] = $_GET[project]; }
if ($_GET[table]) { $_SESSION[var_table] = $_GET[table]; }
$project=$_SESSION[var_project];
$table=$_SESSION[var_table];
?>
<?php
$sql->QueryItem("SELECT `T582`.`sql` as F582_1 FROM `project` as T582 WHERE `project` = $project");
$sql_582=htmlspecialchars($sql->data[F582_1]);
$project_lup = "$sql_582";
if ($_POST['intern']!='') {
$intern = ($_POST['intern']);
$name = ($_POST['name']);
$title = ($_POST['title']);
$id_field = ($_POST['id_field']);
$width = $_POST['width'];
$height = $_POST['height'];
$where = ($_POST['where']);
$edit_where = ($_POST['edit_where']);
}
?>
<html>
<head>
<link href="list.css" type="text/css" rel=stylesheet>
<meta content="text/css" http-equiv="Content-Style-Type">
<title>Table add</title>
</head>
<body class="top" onload="Insert.<?php
if ($_POST[FOCUS]==441) {echo 'name';}
else if ($_POST[FOCUS]==487) {echo 'width';}
else {echo 'sql';}
?>.focus();">
<form name="Insert" action="postaddtable.php" method="post">
<input type=hidden name="FOCUS" value="">
<table class=enter>
<tr id=title><th colspan=2>Table add</th></tr>
<tr><th>SQL name</th>
<td>
<?php
$current=($_POST['intern']!='');
echo ("<select name=\"intern\" style=\"width: 210px\" OnChange=\"Insert.action=''; Insert.FOCUS.value='441'; Insert.submit();\">");
$sql->QueryTry("show tables from $project_lup");
for ($i = 0; $i < $sql->rows; $i++) { $sql->Fetch($i);
$searchID = $sql->data[0];
$searchshow = $searchID;
echo "<option ";
if ($current && $searchID == $_POST['intern']) {echo "selected ";};
echo "value=\"$searchID\">$searchshow";
echo "</option>\n";
}
echo ("</select>");
?>
</td></tr>
<tr><th>Name</th>
<td>
<?php
$current=($_POST['name']!='');
$strdefault = $intern;
if ($current) {$strdefault = $_POST['name'];}
echo "<input type=text name=\"name\" size=30 value=\"$strdefault\">";
?>
</td></tr>
<tr><th>Title</th>
<td>
<?php
$current=($_POST['title']!='');
$strdefault = $intern;
if ($current) {$strdefault = $_POST['title'];}
echo "<input type=text name=\"title\" size=30 value=\"$strdefault\">";
?>
</td></tr>
<tr><th>ID field</th>
<td>
<?php
$current=($_POST['id_field']!='');
echo ("<select name=\"id_field\" OnChange=\"Insert.action=''; Insert.FOCUS.value='487'; Insert.submit();\">");
$sql->QueryTry("show fields from $project_lup.$intern");
for ($i = 0; $i < $sql->rows; $i++) { $sql->Fetch($i);
$searchID = $sql->data[Field];
$searchshow = $searchID;
echo "<option ";
if ($current && $searchID == $_POST['id_field']) {echo "selected ";};
echo "value=\"$searchID\">$searchshow";
echo "</option>\n";
}
echo ("</select>");
?>
</td></tr>
<tr><th>Width</th>
<td>
<?php
$current=($_POST['width']!='');
$strdefault = 500;
if ($current) {$strdefault = $_POST['width'];}
echo "<input type=text name=\"width\" size=5 value=\"$strdefault\">";
?>
</td></tr>
<tr><th>Height</th>
<td>
<?php
$current=($_POST['height']!='');
$strdefault = 500;
if ($current) {$strdefault = $_POST['height'];}
echo "<input type=text name=\"height\" size=5 value=\"$strdefault\">";
?>
</td></tr>
<tr><th>Where</th>
<td>
<?php
$current=($_POST['where']!='');
$strdefault = $_POST['where'];
echo "<textarea name=\"where\" rows=3 cols=40>$strdefault</textarea>";
?>
</td></tr>
<tr><th>edit_where</th>
<td>
<?php
$current=($_POST['edit_where']!='');
$strdefault = $_POST['edit_where'];
echo "<textarea name=\"edit_where\" rows=3 cols=40>$strdefault</textarea>";
?>
</td></tr>
</table>
<p id=buttons>
<input type=submit value=Add>
<input type=button value=Cancel onClick="window.close()">
</p>
</form>
</body>
</html>