%option explicit%>
<%
ShopCheckAdmin "shopa_editdisplay.asp"
'*******************************
' Version 4.00
' Display fields in one record of one table
' setting field to keyword "NULL" sets field to empty
' Nov 17, 2001
'*******************************
dim rstemp
dim which
dim idfield
dim dbtable, sAction, conn
sAction=Request.form("Action")
if sAction="" then
sAction=Request.form("Action.x")
end if
sError=""
GetInputValues
if dbtable="" then
AdminPageHeader
Response.write LangEditSelectFail & "
"
AdMinPageTrailer
else
EditOpenDatabase conn, database,dbtable
If sAction = "" Then
AdminPageHeader
GenerateForm
AdminPageTrailer
Else
AdminPageHeader
UpdateRecord
GenerateForm
AdminPageTrailer
end if
Shopclosedatabase conn
end if
'************************
Sub GetInputValues
' ID, allows editing a record
which=request.querystring("which")
idfield=request.querystring("idfield")
dbtable=request.querystring("table")
database=request.querystring("database")
ValidateTable
End Sub
'
Sub ValidateTable
'********************************************
'See if user has access to this table
Dim UserTables, i
dim tablecount
if getconfig("XRestrictAdminTables")<>"Yes" then exit sub
UserTables=GetSess("UserTables")
If Isnull(UserTables) then
exit sub
end if
if UserTables="" then
exit Sub
else
UserTables=split(GetSess("UserTables"),",",-1,1)
end if
tablecount=ubound(UserTables)
for i = 0 to tablecount
if ucase(dbtable)=ucase(Usertables(i)) then
exit sub
end if
next
dbtable=""
end sub
Sub GenerateForm
dim sqltemp
sqltemp="select * from " & lcase(dbtable)
sqltemp=sqltemp & " where " & idfield & "=" & which
'Debugwrite sqltemp
set rstemp=conn.execute(sqltemp)
DisplayForm
rstemp.close
set rstemp=nothing
end Sub
'****************************
Sub DisplayForm()
dim keyvalue, howmanyfields, i, fieldname, fieldvalue
keyvalue=rstemp(idfield).value
howmanyfields=rstemp.fields.count -1
%>