<?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[table_ofield]) { $_SESSION[var_table_ofield] = $_GET[table_ofield]; }
if ($_GET[table_order]) { $_SESSION[var_table_order] = $_GET[table_order]; }
$table_ofield=$_SESSION[var_table_ofield];
$table_order=$_SESSION[var_table_order];
?>
<?php
$sql->QueryItem("SELECT table_ofield.field as F799, table_ofield.order as F800 FROM `table_ofield` WHERE table_ofield.table_ofield='$table_ofield' AND table_ofield.table_order='$table_order'");
$field = htmlspecialchars($sql->data['F799']);
$order = htmlspecialchars($sql->data['F800']);
if ($_POST['table_ofield']!='') {
$field = htmlspecialchars($_POST['field']);
$order = htmlspecialchars($_POST['order']);
}
?>
<html>
<head>
<link href="list.css" type="text/css" rel=stylesheet>
<meta content="text/css" http-equiv="Content-Style-Type">
<title>Edit Ordering fields</title>
<script>
function confirmDelete(delUrl) {
if (confirm("Remove Ordering fields?")) {
document.location = delUrl;
}
}
</script>
</head>
<body class="top" onload="document.Edit.<?php
if ($_POST[FOCUS]==799) {echo 'order';}
else {echo 'field';}
?>.focus();">
<form name="Edit" action="postedittable_ofield.php" method="post">
<input type=hidden name="FOCUS" value="">
<?php echo("<input type=hidden name=\"table_ofield\" size=5 value=\"$table_ofield\">\n");?>
<table class=enter>
<tr id=title><th colspan=2>Edit Ordering fields</th></tr>
<tr><th>Field</th>
<td>
<?php
echo ("<select name=\"field\" style=\"width: 175px\" OnChange=\"Edit.action=''; Edit.FOCUS.value='799'; Edit.submit();\">");
$sql->Query("select concat('`',`table`.name,'`.`',field.name,'`') as name from field inner join `table` on field.table=`table`.table order by `table`.name, `field`.name");
for ($i = 0; $i < $sql->rows; $i++) {
$sql->Fetch($i);
$searchID = $sql->data[name];
$searchShow = $searchID;
echo "<option ";
if ($searchID == $field) {echo "selected ";};
echo "value=\"$searchID\">$searchShow";
echo "</option>\n";
}
echo ("</select>");
?>
</td></tr>
<tr><th>Order</th>
<td>
<?php echo("<input type=text name=\"order\" size=5 value=\"$order\">");?>
</td></tr>
</table>
<p id=buttons>
<input type=submit value=Change>
<?php
$test=true;
if ($test) {
echo "<input type=button value=Delete onClick=\"confirmDelete('postdeletetable_ofield.php?table_ofield=$table_ofield&table_ofield=$table_ofield&table_order=$table_order')\">\n";
}
?>
<input type=button value="Cancel" onClick="window.close()">
</p>
</form>
</body>
</html>