#function edit_php dbase_id table_id
#query select DatabaseName from `database` where DatabaseID=?dbase_id?
#query select TableID, Subject, TableName, Title, Checks, Session, IDfield from `tables` where TableID=?table_id?
#print page_header 'edit' dbase_id table_id
#print '<?php\n'
#record select Code from actions where TableID=?table_id? and Action='edit' and Part='session'
#print Code ^ '\n'
#end
#set tests=''
#record select FieldName, SessionVar from `fields` where TableID=?table_id? and SessionVar<>'' and FieldName<>'' order by `order`
#if tests=''
#set tests=' WHERE '
#else
#set tests=tests ^ ' AND '
#end
#set tests=tests ^ TableName ^ '.' ^ FieldName ^ '=\'$' ^ SessionVar ^ '\''
#end
#record select fieldID, `Add`, Name, FieldName, `Type`, DisplayName, DisplayLength, Help, areaheight, areawidth, LookupTable, OrderByField, LookupIDField, SessionVar, LookupDisplayField from `fields` where TableID=?table_id? and LookupTable<>'' and (Record='show' or Edit='show' or DisplayName='') order by `order`
#print '$sql->QueryItem(\"SELECT ' ^ queryvars ('T' ^ fieldID) LookupDisplayField fieldID 1 ^ ' FROM `' ^ LookupTable ^ '` as T' ^ fieldID ^ ' WHERE `' ^ LookupIDField ^ '` = $' ^ SessionVar ^ '\");\n'
#set getvars=''
#set expr=fieldreplace LookupDisplayField fieldID
#print getvars
#print ' $' ^ Name ^ '_lup = \"' ^ expr ^ '\";\n'
#end
#print '$sql->QueryItem(\"SELECT '
#set first=true
#record select fieldID, `Record`, FieldName, `Type`, DisplayName, DisplayLength, SessionVar, Help, areaheight, areawidth, ListWidth, LookupTable, OrderByField, LookupIDField, LookupDisplayField from `fields` where TableID=?table_id? and FieldName<>'' and SessionVar='' order by `order`
#if not first
#print ', '
#end
# if LookupDisplayField=''
#print TableName ^ '.' ^ FieldName ^ ' as F' ^ fieldID
# else
# print queryvars ('T' ^ fieldID) LookupDisplayField fieldID 1
# end
#set first=false
#end
#print ' FROM `' ^ TableName ^ '` ' ^ tests ^ '\");\n'
#set first=true
#record select fieldID, Name, FieldName, `Type`, DisplayName, DisplayLength, areaheight, areawidth, LookupTable, OrderByField, LookupIDField, LookupDisplayField from `fields` where TableID=?table_id? and FieldName<>'' and SessionVar='' order by `order`
#if Type='varchar' or Type='text'
#print '$' ^ Name ^ ' = $sql->data[\'F' ^ fieldID ^ '\'];\n'
#else
#if Type='password'
#print '$' ^ Name ^ ' = \'\';\n'
#else
#if Type='date'
#print 'preg_match (\'/^(\d+)-0?(\d+)-0?(\d+)$/\', $sql->data[\'F' ^ fieldID ^ '\'], $matches);\n'
#print '$' ^ Name ^ '=\"$matches[3]/$matches[2]/$matches[1]\";\n'
#else
#print '$' ^ Name ^ ' = $sql->data[\'F' ^ fieldID ^ '\'];\n'
#end
#end
#end
#end
#print 'if ($_POST[\'' ^ IDfield ^ '\']!=\'\') {\n'
#record select Name, FieldName, `Type`, DisplayName, DisplayLength, areaheight, areawidth, LookupTable, OrderByField, LookupIDField, LookupDisplayField from `fields` where TableID=?table_id? and Record<>'none' and FieldName<>'' order by `order`
#if Type='varchar' or Type='text'
#print ' $' ^ Name ^ ' = ($_POST[\'' ^ FieldName ^ '\']);\n'
#else
#if Type='password'
#print '$' ^ Name ^ ' = \'\';\n'
#else
#if Type='date'
#print '$' ^ Name ^ ' = date(\'j/n/Y\', strtotime($_POST[\'' ^ FieldName ^ '\']));\n'
#else
#print '$' ^ Name ^ ' = $_POST[\'' ^ FieldName ^ '\'];\n'
#end
#end
#end
#end
#print '}\n'
#print '?>\n'
#print '<HTML>\n'
#print '<HEAD>\n'
#print ' <META HTTP-EQUIV=\"CONTENT-TYPE\" CONTENT=\"text/html; charset=windows-1252\">\n'
#print ' <TITLE>' ^ Title ^ ' wijzigen</TITLE>\n'
#print '<script>\n'
#print 'function confirmDelete(delUrl) {\n'
#print ' if (confirm(\"' ^ Title ^ ' verwijderen?\")) {\n'
#print ' document.location = delUrl;\n'
#print ' }\n'
#print '}\n'
#print '</script>\n'
#print '</HEAD>\n'
#print '<BODY LANG=\"en-US\" DIR=\"LTR\">\n'
#print '<FORM NAME=\"Edit\" ACTION=\"postedit' ^ Subject ^ '.php\" METHOD=POST>\n'
#print '<?php echo(\"<INPUT TYPE=HIDDEN NAME=\\"' ^ IDfield ^ '\\" SIZE=5 VALUE=\\"$' ^ IDfield ^ '\\">\");?>\n'
#print '<TABLE WIDTH=100% BORDER=0 CELLPADDING=4 CELLSPACING=1>\n'
#print ' <THEAD>\n'
#print ' <TR>\n'
#print ' <TD COLSPAN=2 WIDTH=100% VALIGN=TOP BGCOLOR=\"#000080\">\n'
#print ' <P><FONT COLOR=\"#ffffff\"><FONT FACE=\"Verdana, sans-serif\"><FONT SIZE=1 STYLE=\"font-size: 8pt\">'
#print '<B>' ^ Title ^ ' wijzigen\n'
#print ' </B></FONT></FONT></FONT></P>\n'
#print ' </TD>\n'
#print ' </TR>\n'
#print ' </THEAD>\n'
#print ' <TBODY>\n'
#record select FieldID, `Record`, `Edit`, FieldName, Name, `Type`, DisplayName, SessionVar, Help, AreaHeight, ListWidth*7 as pxwidth, ListWidth, LookupTable, OrderByField, LookupIDField, LookupDisplayField, `default` from `fields` where TableID=?table_id? and FieldName<>'' and Record<>'none' and `Edit`<>'false' order by `order`
#if SessionVar<>''
#print ' <INPUT TYPE=HIDDEN NAME=\"' ^ SessionVar ^ '\" VALUE=\"<?php echo $' ^ SessionVar ^ '; ?>\">\n'
#end
#if Record='show' or Edit='show'
#print ' <TR VALIGN=TOP>\n'
#print ' <TD WIDTH=20% BGCOLOR=\"#e6e6ff\">\n'
#print ' <FONT COLOR=\"#000080\" FACE=\"Verdana, sans-serif\" STYLE=\"font-size: 8pt\">\n'
#print ' ' ^ DisplayName ^'\n'
#print ' </FONT>\n'
#print ' </TD>\n'
#print ' <TD WIDTH=80%>\n'
#print ' <FONT COLOR=\"#000080\" FACE=\"Verdana, sans-serif\" STYLE=\"font-size: 10pt\">\n'
#print ' <?php echo ($' ^ Name ^ (if LookupTable<>'' then '_lup' else '') ^ '); ?>\n'
#print ' </FONT>\n'
#print ' </TD>\n'
#end
#if Record<>'show' and Edit<>'show'
#print ' <TR VALIGN=TOP>\n'
#print ' <TD WIDTH=20% BGCOLOR=\"#e6e6ff\">\n'
#print ' <FONT COLOR=\"#000080\" FACE=\"Verdana, sans-serif\" STYLE=\"font-size: 8pt\">\n'
#print ' ' ^ DisplayName ^'\n'
#print ' </FONT>\n'
#print ' </TD>\n'
#print ' <TD WIDTH=80%>\n'
#print ' <P><FONT COLOR=\"#000080\"><FONT FACE=\"Verdana, sans-serif\"><FONT SIZE=1 STYLE=\"font-size: 8pt\">\n'
#if LookupTable<>''
#print ' <?php\n'
#if pxwidth<>'0'
#print ' echo (\"<SELECT NAME=\\\"' ^ FieldName ^ '\\\" STYLE=\\\"width: ' ^ pxwidth ^ 'px\\\" OnChange=\\\"Edit.action=\'\'; Edit.submit();\\\">\");\n'
#else
#print ' echo (\"<SELECT NAME=\\\"' ^ FieldName ^ '\\\" OnChange=\\\"Edit.action=\'\'; Edit.submit();\\\">\");\n'
#end
#if default='<empty>'
#print ' echo \"<OPTION VALUE=\\\"\\\"></OPTION>\";\n'
#end
#if LookupDisplayField=''
#print ' $sql->Query(\"' ^ LookupTable ^ '\");\n'
#else
#print ' $sql->Query(\"SELECT '
#print queryvars '' LookupDisplayField '0' 1 ^ ', `' ^ LookupTable ^ '`.' ^ LookupIDField
#print ' FROM `' ^ LookupTable ^'` '
#set wcheck=''
#query select Checks as wcheck from `tables` where databaseID=?dbase_id? and TableName=?LookupTable?
#if wcheck<>''
#print ' \n WHERE ' ^ fieldreplace wcheck '0' ^ '\n'
#end
#print ' ORDER BY `' ^ LookupTable ^ '`.' ^ OrderByField ^ ' ASC\");\n'
#end
#print ' for ($i = 0; $i < $sql->rows; $i++)\n'
#print ' {\n'
#print ' $sql->Fetch($i);\n'
#print ' $opzoekID = $sql->data[' ^ LookupIDField ^ '];\n'
#if LookupDisplayField=''
#print ' $opzoekweergave = $opzoekID;\n'
#else
#set expr=fieldreplace LookupDisplayField '0'
#print getvars
#print ' $opzoekweergave = \"' ^ expr ^ '\";\n'
#end
#print ' echo (\"<OPTION \");\n'
#print ' if ($opzoekID == $' ^ Name ^') {echo \"SELECTED \";};\n'
#print ' echo \"VALUE=\\\"$opzoekID\\\">$opzoekweergave\";\n'
#print ' }\n'
#print ' echo (\"</SELECT>\");\n'
#print ' ?>\n'
#else
#if Type='enum'
#print ' <?php\n'
#if pxwidth<>'0'
#print ' echo (\"<SELECT NAME=\\\"' ^ FieldName ^ '\\\" STYLE=\\\"width: ' ^ pxwidth ^ 'px\\\" OnChange=\\\"Edit.action=\'\'; Edit.submit();\\\">\");\n'
#else
#print ' echo (\"<SELECT NAME=\\\"' ^ FieldName ^ '\\\" OnChange=\\\"Edit.action=\'\'; Edit.submit();\\\">\");\n'
#end
#set val=enum data_connection TableName FieldName
#split res=val on ,
#match res with '\(.*\)' into res
#print ' if ($'^ Name ^'==\''^res^'\') {\n'
#print ' echo \"<OPTION VALUE=\\\"' ^ res ^ '\\\" SELECTED>' ^ res ^ '</OPTION>\\n\";\n'
#print ' } else {\n'
#print ' echo \"<OPTION VALUE=\\\"' ^ res ^ '\\\">' ^ res ^ '</OPTION>\\n\";\n'
#print ' }\n'
#end
#end
#print ' echo (\"</SELECT></FONT></FONT>\");\n'
#print ' ?>\n'
#end
#if Type='int' or Type='date' or Type='varchar' or Type='ordering' or Type='password'
#print ' <?php echo(\"<INPUT TYPE=TEXT NAME=\\"' ^ FieldName ^ '\\" SIZE=' ^ ListWidth ^ ' VALUE=\\"$' ^ Name ^ '\\">\");?>\n'
#end
#if Type='text' or Type='mediumtext' or Type='longtext'
#print ' <?php echo(\"<TEXTAREA NAME=\\"' ^ FieldName ^ '\\" ROWS=' ^ AreaHeight ^ ' COLS=' ^ ListWidth ^ '>$' ^ Name ^ '</TEXTAREA>\");?>\n'
#end
#end
#if Help<>''
#print ' <INPUT TYPE=BUTTON VALUE=\"Help\" onClick=\"javascript: window.open(\'vraagbaak.php?zoekitem=' ^ Help ^ '\',\'Help\',\'width=300,height=500,location=no,menubar=no,scrollbars=yes,status=no,resizable=yes\'); return false;\">\n'
#end
#print ' </FONT></FONT></FONT></P>\n'
#print ' </TD>\n'
#print ' </TR>\n'
#end
#end
#print ' </TBODY>\n'
#print '</TABLE>\n'
#print '<P ALIGN=RIGHT>\n'
#set Code=''
#query select Code from actions where TableID=?table_id? and Action='edit' and Part='complete'
#if Code<>''
#print '<?php\n'
#print 'if ('^ Code ^') { echo \"<INPUT TYPE=submit VALUE=Change>\\n\"; }\n'
#print '?>\n'
#else
#print '<INPUT TYPE=\"submit\" VALUE=\"Change\">\n'
#end
#set sesvars=''
#record select SessionVar from `fields` where TableID=?table_id? and SessionVar<>'' order by `order`
#set sesvars=sesvars ^ '&' ^ SessionVar ^ '=$' ^ SessionVar
#end
#print '<?php\n'
#print '$test=true;\n'
#print 'if ($test) {\n'
#print ' echo (\"\n'
#print ' <INPUT TYPE=BUTTON VALUE=\\"Delete\\" onClick=\\"confirmDelete(\'postdelete' ^ Subject ^ '.php?' ^ IDfield ^ '=$' ^ IDfield ^ sesvars ^ '\')\\">\n'
#print ' \");\n'
#print '}\n'
#print '?>\n'
#print '<INPUT TYPE=BUTTON VALUE=\"Cancel\" onClick=\"window.close()\">\n'
#print '</P>\n'
#print '</FORM>\n'
#record select Code from actions where TableID=?table_id? and Action='edit' and Part='footer'
#print '<?php\n' ^ Code ^ '\n?>\n'
#end
#print '</BODY>\n'
#print '</HTML>\n'
#end
#function postedit_php dbase_id table_id
#query select DatabaseName from `database` where DatabaseID=?dbase_id?
#query select TableName, Subject, Checks, Session, IDfield, Include, ListOrderByField from `tables` where TableID=?table_id?
#print page_header 'postedit' dbase_id table_id
#print '<?php\n'
#print '$sql = new MySQL_class;\n'
#print '$sql->Create(\"' ^ DatabaseName ^ '\");\n'
#print '$' ^ IDfield ^ '=($_POST[\'' ^ IDfield ^ '\']);\n'
#record select FieldName, `Type`, DisplayName, DisplayLength, areaheight, areawidth, LookupTable, OrderByField, LookupIDField, LookupDisplayField from `fields` where TableID=?table_id? and `Record`<>'none' and FieldName<>'' order by `order`
#if Type='date'
#print 'preg_match (\'/^(\d+)\/(\d+)\/(\d+)$/\', $_POST[\'' ^ FieldName ^ '\'], $matches);\n'
#print '$' ^ FieldName ^ '=\"\'$matches[3]-$matches[2]-$matches[1]\'\";\n'
#else
#print '$' ^ FieldName ^ '=quote($_POST[\'' ^ FieldName ^ '\']);\n'
#end
#if LookupTable<>''
#set str=fieldreplace LookupTable '0'
#print ' $field = $sql->data[' ^ FieldName ^ '];\n'
#print ' if ($field <> 0) {\n'
#split qry=str on ; +
#print ' $esql->QueryItem(\"' ^ qry ^ ' and `' ^ LookupIDField ^ '`=$field\");\n'
#if string_sub qry 0 4<>'use '
#print 'if ($esql->data[LNR]==0) {die (\'No valid data in \\\'' ^ DisplayName ^ '\\\'\'); }\n'
#end
#end
#print ' }\n'
#end
#end
#set tests=''
#record select FieldName, SessionVar from `fields` where TableID=?table_id? and SessionVar<>'' and FieldName<>'' order by `order`
#if tests=''
#set tests=' WHERE '
#else
#set tests=tests ^ ' AND '
#end
#set tests=tests ^ '`' ^ FieldName ^ '`=\'$' ^ SessionVar ^ '\''
#end
#print '$sql->Update(\"UPDATE `' ^ TableName ^ '` SET\n'
#set first=true
#record select FieldName, `Type`, DisplayName, DisplayLength, areaheight, areawidth, LookupTable, OrderByField, LookupIDField, LookupDisplayField from `fields` where TableID=?table_id? and `Record`<>'none' and FieldName<>'' order by `order`
#if Type='password'
#print '\".(($_POST[' ^ FieldName ^']==\'\')?\'\':\"'
#end
#if first
#set first=false
#else
#print ',\n'
#end
#print '`' ^ FieldName ^ '`=$' ^ FieldName
#if Type='password'
#print '\").\"'
#end
#end
#print tests ^ '\");\n'
#print '$affected_rows = $sql->a_rows;\n'
#record select Code from actions where TableID=?table_id? and Action='edit' and Part='onchange'
#print 'if ($affected_rows>0) {\n' ^ Code ^ '\n}\n'
#end
#print 'echo \"<P><FONT FACE=\\\"Verdana, sans-serif\\\"><FONT SIZE=1 STYLE=\\\"font-size: 8pt\\\">\";\n'
#print 'echo \"Er is/zijn $affected_rows records gewijzigd<BR>\";\n'
#record select `Add`, FieldName, `Type`, DisplayName, DisplayLength, areaheight, areawidth, LookupTable, OrderByField, LookupIDField, LookupDisplayField from `fields` where TableID=?table_id? order by `order`
#if Add='true'
#print 'echo \"$' ^ FieldName ^ '<BR>\";\n'
#end
#end
#print 'echo \"</P>\";\n'
#print 'if ($affected_rows=1) {\n'
#print ' echo \"<script>window.opener.location.reload(true)</script>\";\n'
#print ' echo \"<script>window.close(self)</script>\";\n'
#print '}\n'
#record select `Add`, FieldName, `Type`, DisplayName, DisplayLength, areaheight, areawidth, LookupTable, OrderByField, LookupIDField, LookupDisplayField, SessionVar from `fields` where TableID=?table_id? and FieldName<>'' and FieldName<>?IDfield? and FieldName=?ListOrderByField?
#if SessionVar<>''
#print '$_SESSION[last_'^table_id^']=\'$' ^ SessionVar ^'\';\n'
#else
#print '$_SESSION[last_'^table_id^']=$' ^ FieldName ^ ';\n'
#end
#end
#print '?>\n'
#print '<INPUT TYPE=BUTTON VALUE=\"Close\" onClick=\"window.opener.location.reload(true);self.close()\">\n'
#end
#function rights_edit_php dbase_id table_id
#query select DatabaseName from `database` where DatabaseID=?dbase_id?
#query select TableID, Subject, TableName, Title, Checks, Session, IDfield from `tables` where TableID=?table_id?
#print page_header 'edit' dbase_id table_id
#print '<?php\n'
#record select Code from actions where TableID=?table_id? and Action='edit' and Part='session'
#print Code ^ '\n'
#end
#print '?>\n'
#print '<HTML>\n'
#print '<HEAD>\n'
#print ' <META HTTP-EQUIV=\"CONTENT-TYPE\" CONTENT=\"text/html; charset=windows-1252\">\n'
#print ' <TITLE>' ^ Title ^ ' rechten</TITLE>\n'
#print '</HEAD>\n'
#print '<BODY LANG=\"en-US\" DIR=\"LTR\">\n'
#print '<TABLE WIDTH=100% BORDER=0 CELLPADDING=4 CELLSPACING=1>\n'
#print ' <THEAD>\n'
#print ' <TR>\n'
#print ' <TD COLSPAN=2 WIDTH=100% VALIGN=TOP BGCOLOR=\"#000080\">\n'
#print ' <P><FONT COLOR=\"#ffffff\"><FONT FACE=\"Verdana, sans-serif\"><FONT SIZE=1 STYLE=\"font-size: 8pt\">'
#print '<B>' ^ Title ^ ' rechten\n'
#print ' </B></FONT></FONT></FONT></P>\n'
#print ' </TD>\n'
#print ' </TR>\n'
#print ' </THEAD>\n'
#print ' <TBODY>\n'
#set Help=''
#record select `FieldID`, `Record`, FieldName, `Type`, DisplayName, SessionVar, Help, AreaHeight, ListWidth*7 as pxwidth, ListWidth, LookupTable, OrderByField, LookupIDField, LookupDisplayField from `fields` where TableID=?table_id? and FieldName<>'' and Record<>'none' order by `order`
#print ' <TR VALIGN=TOP>\n'
#print ' <TD WIDTH=20% BGCOLOR=\"#e6e6ff\">\n'
#print ' <FONT COLOR=\"#000080\" FACE=\"Verdana, sans-serif\" STYLE=\"font-size: 8pt\">\n'
#print ' ' ^ DisplayName ^'\n'
#print ' </FONT>\n'
#print ' </TD>\n'
#print ' <TD WIDTH=80%>\n'
#print field_rights_link FieldID 'readonly'
#print field_rights_link FieldID 'hide'
#print ' </TD>\n'
#end
#if Help<>''
#print ' <INPUT TYPE=BUTTON VALUE=\"Help\" onClick=\"javascript: window.open(\'vraagbaak.php?zoekitem=' ^ Help ^ '\',\'Help\',\'width=300,height=500,location=no,menubar=no,scrollbars=yes,status=no,resizable=yes\'); return false;\">\n'
#end
#print ' </FONT></FONT></FONT></P>\n'
#print ' </TD>\n'
#print ' </TR>\n'
#print ' </TBODY>\n'
#print '</TABLE>\n'
#print '<P ALIGN=RIGHT>\n'
#print '<INPUT TYPE=\"submit\" VALUE=\"Change\" onClick=\"window.close()\">\n'
#print '<INPUT TYPE=BUTTON VALUE=\"Delete\" onClick=\"window.close()\">\n'
#set part=''
#query select `part` from `part` where `table`=?table_id? and `link`=`screen`
#if part<>''
#print part_rights_link part 'nodelete'
#end
#print '<INPUT TYPE=BUTTON VALUE=\"Cancel\" onClick=\"window.close()\">\n'
#print '</P>\n'
#print '</FORM>\n'
#record select Code from actions where TableID=?table_id? and Action='edit' and Part='footer'
#print '<?php\n' ^ Code ^ '\n?>\n'
#end
#print '</BODY>\n'
#print '</HTML>\n'
#end
#function generate_edit dbase_id table_id
#query select DatabaseName from `database` where DatabaseID=?dbase_id?
#query select TableID, Subject, TableName, Title, Checks, Session, IDfield from `tables` where TableID=?table_id?
#print '<div><FORM NAME=Edit METHOD=POST>\n<?php\n'
#record select FieldName, `Type`, DisplayName, DisplayLength, areaheight, areawidth, LookupTable, OrderByField, LookupIDField, LookupDisplayField from `fields` where TableID=?table_id? and Record<>'none' and FieldName<>'' order by `order`
#print 'if ($_POST[\'' ^ FieldName ^ '\']!=\'\') {\n'
#if Type='varchar' or Type='text'
#print ' $' ^ FieldName ^ ' = ($_POST[\'' ^ FieldName ^ '\']);\n'
#else
#if Type='password'
#print ' $' ^ FieldName ^ ' = \'\';\n'
#else
#if Type='date'
#print ' $' ^ FieldName ^ ' = date(\'j/n/Y\', strtotime($_POST[\'' ^ FieldName ^ '\']));\n'
#else
#print ' $' ^ FieldName ^ ' = $_POST[\'' ^ FieldName ^ '\'];\n'
#end
#end
#end
#print ' $_SESSION[var_' ^ FieldName ^ ']=$' ^ FieldName ^ ';\n'
#print '}\n'
#end
#record select FieldID, `Record`, FieldName, `Type`, DisplayName, SessionVar, Help, AreaHeight, ListWidth*7 as pxwidth, ListWidth, LookupTable, OrderByField, LookupIDField, LookupDisplayField from `fields` where TableID=?table_id? and FieldName<>'' and Record<>'none' order by `order`
#if Record<>'show'
#if LookupTable<>''
#if pxwidth<>'0'
#print 'echo (\"<SELECT NAME=\\\"' ^ FieldName ^ '\\\" STYLE=\\\"width: ' ^ pxwidth ^ 'px\\\" OnChange=\\\"Edit.action=\'\'; Edit.submit();\\\">\");\n'
#else
#print 'echo (\"<SELECT NAME=\\\"' ^ FieldName ^ '\\\" OnChange=\\\"Edit.action=\'\'; Edit.submit();\\\">\");\n'
#end
#print '$sql->Query(\"SELECT '
#print queryvars 'T' LookupDisplayField '0' 1 ^ ', T.' ^ LookupIDField
#print ' FROM `' ^ LookupTable ^'` as T'
#set wcheck=''
#query select Checks as wcheck from `tables` where databaseID=?dbase_id? and TableName=?LookupTable?
#if wcheck<>''
#print ' \n WHERE ' ^ fieldreplace wcheck '0'
#end
#print '\n ORDER BY ' ^ OrderByField ^ ' ASC\");\n'
#print 'for ($i = 0; $i < $sql->rows; $i++)\n'
#print '{\n'
#print ' $sql->Fetch($i);\n'
#print ' $opzoekID = $sql->data[' ^ LookupIDField ^ '];\n'
#set expr=fieldreplace LookupDisplayField '0'
#print getvars
#print ' $opzoekweergave = \"' ^ expr ^ '\";\n'
#print ' echo (\"<OPTION \");\n'
#print ' if ($opzoekID == $' ^ FieldName ^') {echo \"SELECTED \";};\n'
#print ' echo \"VALUE=\\\"$opzoekID\\\">$opzoekweergave\";\n'
#print '}\n'
#print 'echo (\"</SELECT>\");\n'
#else
#if Type='enum'
#if pxwidth<>'0'
#print 'echo (\"<SELECT NAME=\\\"' ^ FieldName ^ '\\\" STYLE=\\\"width: ' ^ pxwidth ^ 'px\\\" OnChange=\\\"Edit.action=\'\'; Edit.submit();\\\">\");\n'
#else
#print 'echo (\"<SELECT NAME=\\\"' ^ FieldName ^ '\\\" OnChange=\\\"Edit.action=\'\'; Edit.submit();\\\">\");\n'
#end
#set val=enum data_connection TableName FieldName
#split res=val on ,
#match res with '\(.*\)' into res
#print 'if ($'^ FieldName ^'==\''^res^'\') {\n'
#print ' echo \"<OPTION VALUE=\\\"' ^ res ^ '\\\" SELECTED>' ^ res ^ '</OPTION>\\n\";\n'
#print '} else {\n'
#print ' echo \"<OPTION VALUE=\\\"' ^ res ^ '\\\">' ^ res ^ '</OPTION>\\n\";\n'
#print '}\n'
#end
#end
#print 'echo (\"</SELECT>\");\n'
#end
#if Type='int' or Type='date' or Type='varchar' or Type='password'
#print 'echo(\"<INPUT TYPE=TEXT NAME=\\"' ^ FieldName ^ '\\" SIZE=' ^ ListWidth ^ ' VALUE=\\"$' ^ FieldName ^ '\\">\");\n'
#end
#if Type='text' or Type='mediumtext' or Type='longtext'
#print 'echo(\"<TEXTAREA NAME=\\"' ^ FieldName ^ '\\" ROWS=' ^ AreaHeight ^ ' COLS=' ^ ListWidth ^ '>$' ^ FieldName ^ '</TEXTAREA>\");\n'
#end
#end
#end
#end
#set Code=''
#query select Code from actions where TableID=?table_id? and Action='edit' and Part='complete'
#if Code<>''
#print 'if ('^ Code ^') { echo \"<INPUT TYPE=submit VALUE=Alter>\\n\"; }\n'
#else
#print 'echo \"<INPUT TYPE=submit VALUE=Alter>\\n\";\n'
#end
#print '?></FORM></div>\n'
#end