adamy
asked on
how to make a "next page" and "last page" in a wincgi?
I want to list my table in browser,but the table is 1000 rows.I want to display it page by page,when I display one page, there are two button "next page" and "last page" at the bottom.What should I do?
Now I have a program to do it, but it can not work,the first page is right,the the next page is same as first page, what should I do?
project is yy.exe:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, HTTPApp, DBTables, Db;
type
TWebModule1 = class(TWebModule)
Database1: TDatabase;
Query1: TQuery;
Session1: TSession;
PageProducer1: TPageProducer;
procedure WebModule1Create(Sender: TObject);
procedure WebModule1WebActionItem1Ac tion(Sende r: TObject;
Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
procedure PageProducer1HTMLTag(Sende r: TObject; Tag: TTag;
const TagString: String; TagParams: TStrings;
var ReplaceText: String);
procedure WebModule1WebActionItem2Ac tion(Sende r: TObject;
Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
private
{ Private declarations }
public
{ Public declarations }
end;
var
WebModule1: TWebModule1;
t_addr_c:string;
t_name_c:string;
aa:string;
implementation
{$R *.DFM}
procedure TWebModule1.WebModule1Crea te(Sender: TObject);
begin
query1.close;
query1.open;
query1.FindFirst;
t_name_c:=query1.fieldbyna me('e_name _c').asstr ing;
t_addr_c:=query1.FieldByNa me('e_addr _c').asstr ing;
end;
procedure TWebModule1.WebModule1WebA ctionItem1 Action(Sen der: TObject;
Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
begin
query1.open;
response.content:=pageprod ucer1.Cont ent;
end;
procedure TWebModule1.PageProducer1H TMLTag(Sen der: TObject; Tag: TTag;
const TagString: String; TagParams: TStrings; var ReplaceText: String);
var i:integer;
begin
if compareText(tagString,'tt' )=0 then
begin
aa:='';
for i:=1 to 5 do
begin
aa:=aa+'<tr>'+
'<td width="240" bgcolor="#E8F3FF" height="18">'+
trim(t_name_c)+
'<p style="line-height: 100%; margin-top: 1; margin-bottom: 1">¡¡</td>'+
'<td width="366" bgcolor="#E8F3FF" height="18">'+
trim(t_addr_c)+
'<p style="line-height: 100%; margin-top: 1; margin-bottom: 1">¡¡</td>'+
'</tr>';
query1.findNext;
t_name_c:=query1.fieldbyna me('e_name _c').asstr ing;
t_addr_c:=query1.FieldByNa me('e_addr _c').asstr ing;
end;
replacetext:=aa;
end;
end;
procedure TWebModule1.WebModule1WebA ctionItem2 Action(Sen der: TObject;
Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
begin
response.content:=pageprod ucer1.Cont ent;
end;
end.
in pageproducer1.htmldoc:
<html>
<head>
<meta http-equiv="Content-Langua ge" content="zh-cn">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor. Document">
<style type="text/css"><!-- A{TEXT-DECORATION:none}--> </style>
<base target="_self">
<title></title>
<style fprolloverstyle>A:hover {color: #FF0000}
</style>
</head>
<body link="#000000">
<table border="1" cellpadding="0" width="100%" height="282">
<tr>
<td bgcolor="#66CCFF" width="240" height="18">
<p align="center" style="line-height: 100%; margin-top: 1; margin-bottom: 1"><font size="2">name</font></td>
<td bgcolor="#66CCFF" width="366" height="18">
<p align="center" style="line-height: 100%; margin-top: 1; margin-bottom: 1"><font size="2">address</font></t d>
</tr>
<#tt>
</table>
<p align="center" style="line-height: 100%; margin-top: 0; margin-bottom: 0">   ;</p>
<p align="center" style="line-height: 100%; margin-top: 0; margin-bottom: 0"> <a href="http://yangdong/scripts/yy.exe/last" target="_parent">last page</a>
<a href="http://yangdong/scripts/yy.exe/next" target="_parent">next page</a></font></span></p>
</td>
</tr>
</table>
</body>
</html>
Now I have a program to do it, but it can not work,the first page is right,the the next page is same as first page, what should I do?
project is yy.exe:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, HTTPApp, DBTables, Db;
type
TWebModule1 = class(TWebModule)
Database1: TDatabase;
Query1: TQuery;
Session1: TSession;
PageProducer1: TPageProducer;
procedure WebModule1Create(Sender: TObject);
procedure WebModule1WebActionItem1Ac
Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
procedure PageProducer1HTMLTag(Sende
const TagString: String; TagParams: TStrings;
var ReplaceText: String);
procedure WebModule1WebActionItem2Ac
Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
private
{ Private declarations }
public
{ Public declarations }
end;
var
WebModule1: TWebModule1;
t_addr_c:string;
t_name_c:string;
aa:string;
implementation
{$R *.DFM}
procedure TWebModule1.WebModule1Crea
begin
query1.close;
query1.open;
query1.FindFirst;
t_name_c:=query1.fieldbyna
t_addr_c:=query1.FieldByNa
end;
procedure TWebModule1.WebModule1WebA
Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
begin
query1.open;
response.content:=pageprod
end;
procedure TWebModule1.PageProducer1H
const TagString: String; TagParams: TStrings; var ReplaceText: String);
var i:integer;
begin
if compareText(tagString,'tt'
begin
aa:='';
for i:=1 to 5 do
begin
aa:=aa+'<tr>'+
'<td width="240" bgcolor="#E8F3FF" height="18">'+
trim(t_name_c)+
'<p style="line-height: 100%; margin-top: 1; margin-bottom: 1">¡¡</td>'+
'<td width="366" bgcolor="#E8F3FF" height="18">'+
trim(t_addr_c)+
'<p style="line-height: 100%; margin-top: 1; margin-bottom: 1">¡¡</td>'+
'</tr>';
query1.findNext;
t_name_c:=query1.fieldbyna
t_addr_c:=query1.FieldByNa
end;
replacetext:=aa;
end;
end;
procedure TWebModule1.WebModule1WebA
Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
begin
response.content:=pageprod
end;
end.
in pageproducer1.htmldoc:
<html>
<head>
<meta http-equiv="Content-Langua
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.
<style type="text/css"><!-- A{TEXT-DECORATION:none}-->
<base target="_self">
<title></title>
<style fprolloverstyle>A:hover {color: #FF0000}
</style>
</head>
<body link="#000000">
<table border="1" cellpadding="0" width="100%" height="282">
<tr>
<td bgcolor="#66CCFF" width="240" height="18">
<p align="center" style="line-height: 100%; margin-top: 1; margin-bottom: 1"><font size="2">name</font></td>
<td bgcolor="#66CCFF" width="366" height="18">
<p align="center" style="line-height: 100%; margin-top: 1; margin-bottom: 1"><font size="2">address</font></t
</tr>
<#tt>
</table>
<p align="center" style="line-height: 100%; margin-top: 0; margin-bottom: 0">  
<p align="center" style="line-height: 100%; margin-top: 0; margin-bottom: 0"> <a href="http://yangdong/scripts/yy.exe/last" target="_parent">last page</a>
<a href="http://yangdong/scripts/yy.exe/next" target="_parent">next page</a></font></span></p>
</td>
</tr>
</table>
</body>
</html>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER