根据需求,数据库操作的经验我们要达到下图这样一个结果
图片如下:
现在来制定一个函数实现中间的数据表(director中支持简单的html语句,并且是所有文本结构中执行效率最快的)
制订函数updatedb带有两个参数佛fromres和zcount
on updatedb fromres,zcount
FieldList = adodb.Xa_FetchFieldList(fromres)
--得到字段名列表
fields = adodb.Xa_FieldCount(fromres)
--得到字段名列表的字段数
set content="<html><body bgcolor=#ffffff><table border=1><tr height=30 bgcolor=#ff9900 >"
--设定变量content为html的一些固定内容
repeat with i = 1 to fields
--循环单元格得到一行表格为数据库的表头
set content= content&"<td><font size=5 color=#ffffff><b>"&FieldList[i]&"</b></font></td>"
end repeat
set content= content&"</tr>"
repeat with k = 1 to zcount
--循环得到当前指针及其后共 zcount条记录
row=adodb.Xa_FetchRowList(fromres)
--得到当前记录的列表
set content= content&"<tr height=20 bgcolor=#eeeeee>"
repeat with i = 1 to fields
--循环单元格得到一行表格为数据库的当前记录行
set content= content&"<td width="&tablewidth[i]&">"&row[i]&"</td>"
end repeat
set content= content&"</tr>"
adodb.Xa_Next(fromres)
移动到下一条记录
end repeat
set content= content&"</table><body><html>"
return content
返回content
end
与上面语句结合,得到一页表格只需要写
member("dbdable").html=updatedb(res,zlinecount)就可以了
到此实现了第一页,再加上上页下页,最前,最后进行分页就可以实现一个简单的查询了
下面语句通过当前页page变量的加减和adodb.Xa_Goto语句实现了上页下页,最前,最后功能
上页语句
if page>1 then
page=page-1
adodb.Xa_Goto(res,zlinecount*(page-1)+1)
member("dbtable").html=updatedb(res,zlinecount)
end if
下页语句
if page<pages then
page=page+1
adodb.Xa_Goto(res,zlinecount*(page-1)+1)
member("dbtable").html=updatedb(res,zlinecount,)
end if
最前语句
if page>1 then
page=1
adodb.Xa_Goto(res,zlinecount*(page-1)+1)
member("dbtable").html=updatedb(res,zlinecount)
end if
最后语句
if page<>pages then
page=pages
adodb.Xa_Goto(res,zlinecount*(page-1)+1)
member("dbtable").html=updatedb(res,zlinecount)
end if