Source: Aesop
Desktop Center (4) Data Display
Author: elong
The last step is to display it.
The following program is called through parameters.
For example, php. php? Jpg = jpg
Jpg is the name of the table. Remember this. Otherwise, the program will fail and an error will be displayed.
You can change the following program. In this way, it will be more beautiful.
The following is the source program:
<Html>
<Head> <title> display </title>
</Head>
<Body>
<?
Mysql_connect ("localhost", "username", "password") or die ("unable to connect to the database! ");
$ Query = "SELECT id, url, mess, fromx, url1, mess1, fromx1, url2, mess2, fromx2, url3, mess3, fromx3 from $ jpg ";
$ Result = mysql_db_query ("elong", $ query); // execute the query
$ Num = mysql_numrows ($ result );
$ Page = round ($ page );
$ Pagesize = 4;
If ($ page = 0 ){
$ Page = 1 ;}
Else {
$ Page = $ page ;}
$ Pagecount = ($ num)/$ pagesize;
$ Pagecount = ceil ($ pagecount );
?>
<? If ($ page! = 1 and $ num! = 0 ){
Printf ("<a href =" % s? Page = % s & jpg = $ jpg "> homepage </a>", $ PHP_SELF, 1 );
Printf ("<a href =" % s? Page = % s & jpg = $ jpg "> previous page </a>", $ PHP_SELF, $ page-1 );
} Else {
?> Homepage front page <?
}
?>
</Font>
<? If ($ page! = $ Pagecount and $ num! = 0 ){
Printf ("<a href =" % s? Page = % s & jpg = $ jpg "> back page </a>", $ PHP_SELF, $ page + 1 );
Printf ("<a href =" % s? Page = % s & jpg = $ jpg "> last page </a>", $ PHP_SELF, $ pagecount );
} Else {?> Last page <?}?> Page: <strong> <? Echo $ page?> </Strong>/<strong> <? Echo $ pagecount?> </Strong> page
</Span> </td>
<?
If ($ num <> 0 ){
$ Pp = 0;
For ($ ipage = 0; $ ipage <$ pagesize; $ ipage ++ ){
$ I = ($ page-1) * $ pagesize + $ ipage;
If ($ I <$ num ){
$ Id = mysql_result ($ result, $ I, "id ");
$ Url = mysql_result ($ result, $ I, "url ");
$ Mess = mysql_result ($ result, $ I, "mess ");
$ Fromx = mysql_result ($ result, $ I, "fromx ");
$ Url1 = mysql_result ($ result, $ I, "url1 ");
$ Mess1 = mysql_result ($ result, $ I, "mess1 ");
$ Fromx1 = mysql_result ($ result, $ I, "fromx1 ");
$ Url2 = mysql_result ($ result, $ I, "url2 ");
$ Mess2 = mysql_result ($ result, $ I, "mess2 ");
$ Fromx2 = mysql_result ($ result, $ I, "fromx2 ");
$ Url3 = mysql_result ($ result, $ I, "url3 ");
$ Mess3 = mysql_result ($ result, $ I, "mess3 ");
$ Fromx3 = mysql_result ($ result, $ I, "fromx3 ");
$ Pp = $ pp + 1;
?>
<Table width = "668" border = "2" cellspacing = "0" cellpadding = "0" align = "center" bordercolor = "# FFFFFF">
<Tr>
<Td width = "167" height = "127"> <a href = "<? Echo $ url?> "Target =" _ blank "> "Width =" 160 "height =" 120 "border =" 4 "> </td>
<Td width = "167" height = "127"> <a href = "<? Echo $ url1?> "Target =" _ blank "> "Width =" 160 "height =" 120 "border =" 4 "> </td>
<Td width = "167" height = "127"> <a href = "<? Echo $ url2?> "Target =" _ blank "> "Width =" 160 "height =" 120 "border =" 4 "> </td>
<Td width = "167" height = "127"> <a href = "<? Echo $ url3?> "Target =" _ blank "> "Width =" 160 "height =" 120 "border =" 4 "> </td>
</Tr>
</Table>
<?
}
}
}
?>
<Td nowrap align = center> <span class = smallFont> <span class = titleFont> paging </span>
<Font color = darkgray> <? If ($ page! = 1 and $ num! = 0 ){
Printf ("<a href =" % s? Page = % s & jpg = $ jpg "> homepage </a>", $ PHP_SELF, 1 );
Printf ("<a href =" % s? Page = % s & jpg = $ jpg "> previous page </a>", $ PHP_SELF, $ page-1 );
} Else {
?> Homepage homepage <?}?> </Font> <? If ($ page! = $ Pagecount and $ num! = 0 ){
Printf ("<a href =" % s? Page = % s & jpg = $ jpg "> back page </a>", $ PHP_SELF, $ page + 1 );
Printf ("<a href =" % s? Page = % s & jpg = $ jpg "> last page </a>", $ PHP_SELF, $ pagecount );
} Else {?> Last page <?}?> Page: <strong> <? Echo $ page?> </Strong>/<strong> <? Echo $ pagecount?> </Strong> page
</Span> </td>
</TABLE> </DIV> </CENTER>
</BODY> </HTML>