The message book guestbook. php I wrote using php + mysql:
High school <6> class message book
|
|
Include ("connect. rec ");
$ Qh = mysql_query ("select count (*) AS rcnt FROM guestbook ");
$ Data = mysql_fetch_array ($ qh );
$ Nr = $ data ["rcnt"];
// Determine whether the offset parameter is passed to the script. if not, use the default value 0.
If (empty ($ offset ))
{
$ Offset = 0;
} // Query result (20 entries per page, but you can change it by yourself)
// $ Result = mysql_query ("SELECT * from guestbook order by time desc LIMIT $ offset, 5 "); $ Result = mysql_query ("SELECT * from guestbook LIMIT $ offset, 5 ");
// Display the returned five records
While ($ data = mysql_fetch_array ($ result )) { Printf ("name: % s ", $ Data [" name "]); Printf ("EMAIL: % s ", $ Data [" mail "]); Printf ("personal homepage: % s ", $ Data [" url "]); Printf ("From: % s ", $ Data [" ip "]); Printf ("Message Time: % s ", $ Data [" time "]); Printf ("topic: % s ", $ Data [" title "]); Printf ("content: % s ", $ Data [" ly "]); Printf (" "); }
// Next, write the link to another page
If ($ offset) // if the offset is 0, the link to the previous page is not displayed. { $ Preoffset = $ offset-5; Print "previous page n "; }
// Calculate the total number of required pages
$ Pages = ceil ($ nr/5); // $ pages variable now contains the required page number
For ($ I = 1; $ I <= $ pages; $ I ++)
{
$ Newoffset = 5 * $ I-5;
Print "$ I n ";
}
// Check whether it is the last page $ Next = $ offset + 5; If ($ next <$ nr) { Print "next n "; } Printf ("return ") ?>
|
Ly. php:
Include ("connect. rec ");
$ Name = $ T1;
$ Mail = $ T2;
$ Url = $ T3;
$ Title = $ T4;
$ Time = date ("Y-m-j H: I: s ");
$ Ip = getenv ("REMOTE_ADDR ");
$ Ly = $ S1;
$ Result = mysql_query ("insert into guestbook (name, mail, url, ip, time, title, ly) values ('$ name',' $ mail ', '$ url',' $ IP', '$ time',' $ title', '$ ly ')");
If ($ result = 1)
{
Echo ("message successful! ");
Printf ("