|
Database Full Cycle #1 --
Display Table, Edit Record, Update Record
dbfull1.asp merely displays a table like
we have in other examples, except every row of the table has a hyperlink to dbfull2.asp
and passes the ID to that script in a variable called whichID. After the user edits that
information and presses submit, dbfull3.asp is called. It's task is to
gather all input fields and construct a SQL update statement. Here is a source printout of
the script that displays the table and "starts the ball rolling":
filename=/learn/test/authorshow.asp
<%
response.buffer=true
Response.ExpiresAbsolute = Now() - 1
Response.AddHeader "Cache-Control", "private"
%>
<html><head>
<title>authorshow.asp</title>
<meta http-equiv="pragma" content="no-cache">
</head><body bgcolor="#FFFFFF">
<%
myDSN="DSN=Student;uid=student;pwd=magic"
mySQL="select * from authors where AU_ID<100 order by author"
IDfield="AU_ID"
scriptresponder="authoredit.asp"
set conntemp=server.createobject("adodb.connection")
conntemp.open myDSN
set rstemp=conntemp.execute(mySQL)
howmanyfields=rstemp.fields.count -1
%>
<table border="1">
<tr>
<td valign="top">---</td>
<% 'Put Headings On The Table of Field Names
for i=0 to howmanyfields %>
<td><b><%=rstemp(i).name %></b></td>
<% next %>
</tr>
<% ' Now lets grab all the records
do while not rstemp.eof %>
<tr><td valign="top">
<%my_link=scriptresponder & "?which=" & rstemp(idfield)%>
<a HREF="<%=my_link%>">Edit</a></td>
<% for i = 0 to howmanyfields%>
<td valign="top"><%=rstemp(i)%></td>
<% next %>
</tr>
<%
rstemp.movenext
loop
rstemp.close
set rstemp=nothing
conntemp.close
set conntemp=nothing
%>
</table></body></html>
 |  |  |
 |
There are many worthy charities!!. But perhaps help starving children in Africa or South America AND help Charles too.
a $5 tip buys him lunch at McDonalds,
a $20 tip buys his kid Hitoshi a new computer game,
a $39 tip buys his daughter Michiko a few nice outfits.
See our donor list.
|  |
 |  |  |
|
|
|
|