Link to home
Start Free TrialLog in
Avatar of adamy
adamyFlag for Canada

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 WebModule1WebActionItem1Action(Sender: TObject;
      Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
    procedure PageProducer1HTMLTag(Sender: TObject; Tag: TTag;
      const TagString: String; TagParams: TStrings;
      var ReplaceText: String);
    procedure WebModule1WebActionItem2Action(Sender: 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.WebModule1Create(Sender: TObject);
begin
  query1.close;
   query1.open;
   query1.FindFirst;
   t_name_c:=query1.fieldbyname('e_name_c').asstring;
   t_addr_c:=query1.FieldByName('e_addr_c').asstring;


end;

procedure TWebModule1.WebModule1WebActionItem1Action(Sender: TObject;
  Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
begin
      query1.open;
      response.content:=pageproducer1.Content;
end;

procedure TWebModule1.PageProducer1HTMLTag(Sender: 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.fieldbyname('e_name_c').asstring;
     t_addr_c:=query1.FieldByName('e_addr_c').asstring;

      end;
      replacetext:=aa;
   end;
end;

procedure TWebModule1.WebModule1WebActionItem2Action(Sender: TObject;
  Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
begin
      response.content:=pageproducer1.Content;
end;

end.




in pageproducer1.htmldoc:
<html>

<head>
<meta http-equiv="Content-Language" 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></td>
        </tr>

        <#tt>

      </table>
<p align="center" style="line-height: 100%; margin-top: 0; margin-bottom: 0">&nbsp;&nbsp;&nbsp;&nbsp;</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>
Avatar of adamy
adamy
Flag of Canada image

ASKER

Adjusted points to 300
ASKER CERTIFIED SOLUTION
Avatar of 333
333

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial