$#@60;?php
/* $host : your MySQL-host, usually localhost */
/* $user : your MYSQL-username */
/* $password : your MySQL-password */
/* $database : your MySQL-database */
/* $table : your MySQL-table */
/* $page_title : the title of your guestbook-pages */
/* $admin_mail : email-address of the administrator to send the new entries
to */
/* $admin_name : the name of the administrator */
/* $html_mail : say yes if your mail-agent can handle HTML-mail, else
say no */
/* connect to the database */
mysql_pconnect("$host","$user","$password")
or die("Cant connect to the SQL-server");
mysql_select_db("$database");
/* action=view : retrieve data from the database and show it to the user
*/
if($action == "view") {
/* function for showing the data */
function search_it($name) {
/* some vars */
global $offset,$total,$lpp,$dir;
global $table,$html_mail,$admin_name,$admin_mail;
/* select the data to get out of the database */
$query = "SELECT name, email, job, comments FROM $table";
$result = mysql_query($query);
$total= mysql_numrows($result);
print "$#@60;CENTER$#@62;$#@60;FONT FACE=\"Verdana\" SIZE=\"-2\"$#@62;$#@60;A
HREF=\"guestbook.php3?action=add\" onMouseOver=\"window.status=Add
your name;return true\" onMouseOut=\"window.status=;return
true\" TITLE=\"Add your name\"$#@62;加入留言$#@60;/A$#@62;$#@60;/FONT$#@62;$#@60;/CENTER$#@62;$#@60;br$#@62;$#@60;br$#@62;";
if ($total== 0) {
print "$#@60;CENTER$#@62;此刻没人留言$#@60;/CENTER$#@62;$#@60;br$#@62;$#@60;br$#@62;";
}
elseif ($total$#@62; 0) {
/* default */
$counter=0;
if ($dir=="") $dir="Next";
$lpp=5;
if ($offset==0) $offset=0;
if ($dir=="Next") {
if ($total $#@62; $lpp) {
$counter=$offset;
$offset+=$lpp;
$num=$offset;
if ($num $#@62; $total) {
$num=$total; } }
else {
$num=$total; } }
elseif ($dir=="Previous") {
if ($total $#@62; $lpp) {
$offset-=$lpp;
if ($offset $#@60; 0) {
$offset=0; }
$counter=$offset-$lpp;
if ($counter $#@60; 0)
$counter=0;
$num=$counter+$lpp; }
else {
$num=$total; } }
while ($counter $#@60; $num) {
$j=0;
$j=$counter + 1;
/* now really grab the data */
$i1=mysql_result($result,$counter,"name");
$i2=mysql_result($result,$counter,"email");
$i3=mysql_result($result,$counter,"job");
$i4=mysql_result($result,$counter,"comments");
/* See if we need to put on the NEXT or PREVIOUS buttons */
if ($total $#@62; $lpp) {
echo("$#@60;form action=\"$PHP_SCRIPT\" method=\"POST\"$#@62;\n");
/* See if we need a PREVIOUS button */
if ($offset $#@62; $lpp) {
echo("$#@60;input type=\"submit\" value=\"Previous\"
name=dir$#@62;\n"); }
/* See if we need a NEXT button */
if ($offset $#@60; $total) {
echo("$#@60;input type=\"submit\" value=\"Next\"
name=dir$#@62;\n"); }