盾怪网教程:是一个免费提供流行杀毒软件教程、在线学习分享的学习平台!

在线竞拍系统的PHP完成框架(一)

时间:2024/11/26作者:未知来源:盾怪网教程人气:

[摘要]"; if(this->TPages!=0 && this->CPages<this->TPages) echo "<A href=PHP_SE...
";
if($this->TPages!=0 && $this->CPages<$this->TPages)
echo "<A href=$PHP_SELF?offset=".$last.$strQuery.">末页</A>";
}

//******end class
}

?>


//************************
ebid.sql文件(我是用phpmyadmin导出的)

# phpMyAdmin MySQL-Dump
# http://www.htmlwizard.net/phpMyAdmin/
#
# Host: localhost Database : ebid

# --------------------------------------------------------
# Table structure for table 'reply'
# id,商品id,出价人,出价人的email,出价。

CREATE TABLE reply (
id varchar(16) NOT NULL,
parentid varchar(16) NOT NULL,
buyer varchar(12) NOT NULL,
email varchar(32) NOT NULL,
price float(10,2) DEFAULT '0.00' NOT NULL,
PRIMARY KEY (id, price)
);


# --------------------------------------------------------
# Table structure for table 'shop'
# id,商品名,介绍,原始价,加价单位,结束时间,竞标数,当前价,是否有照片

CREATE TABLE shop (
id varchar(16) NOT NULL,
name varchar(50) NOT NULL,
description text,
price float(10,2) DEFAULT '0.00' NOT NULL,
unit tinyint(2) unsigned NOT NULL,
endtime varchar(16) DEFAULT '0000-00-00 00:00' NOT NULL,
reply int(4) unsigned NOT NULL,
curprice float(10,2) DEFAULT '0.00' NOT NULL,
photo tinyint(1) unsigned NOT NULL,
PRIMARY KEY (id),
KEY kreply (reply)
);


配置文件如下:
//**************
//config.inc.php

<?php

$HOST="localhost"; //主机名
$DATABASE="ebid"; //数据库名
$WARE_TABLE="shop"; //商品表
$BID_TABLE="reply"; //回应表
$USER="root"; //用户
$PASSWD="9999"; //密码

$PAGE_MAX_LINE=20; //每页显示行数

//打开数据库
$LinkID=mysql_connect($HOST,$USER,$PASSWD);
mysql_select_db($DATABASE,$LinkID) or die(mysql_error());

?>

以下是显示商品及TOP10商品的函数
//*****************
//
<?php
include "config.inc.php";
include "tview.class.php"; //类文件


//*****显示商品列表********
function PrintList(){
global $view;

$ct=time();

//设置条件的句子!要满足SQL语法哦。只显示没有结束竞标的商品
$view->SetCondition("where endtime>'$ct' order by id desc");

//调用成员函数来读记录
//结果$result[记录号][字段名] 是二维数组。
$result=$view->ReadList();

if($view->Number==0) {echo "<tr><td colspan=4> </td></tr>"; return;}

for($i=0;$i<$view->Number;$i++){
if(ceil($i/2)*2==$i) $bgc="#ffffff";
else $bgc="#f3f3f3";
echo "<tr bgcolor=$bgc><td width=60% >";
echo "<a href="javascript:showdetail('detail.php?id=".$result[$i][id]."')">".$result[$i][name]."</a>";
echo "</td><td width=15% >";
echo date("Y-m-j 24:00:00",$result[$i][endtime]);
echo "</td><td width=15% align=right>¥";
echo $result[$i][curprice];
echo "</td><td width=10% align=right>";
echo $result[$i][reply];
echo "</td></tr>";
}
}

//*********显示最热的10条记录**********
function ListTopHot(){
global $view;

//同样先设置条件
$view->SetCondition("order by reply desc");
//读记录
$result=$view->ReadList();

$k=(count($result)>10)? '10':(count($result));

for($i=0;$i<$k;$i++){
echo "<tr><td>";
echo "<a href="javascript:showdetail('detail.php?id=".$result[$i][id]."')">".$result[$i][name]."</a>";
echo "</td></tr>";
}

}


//*********显示最新10条记录***********
function ListTopNew(){
global $view;

$view->SetCondition("order by id desc");
$result=$view->ReadList();

$k=(count($result)>10)? '10':(count($result));

for($i=0;$i<$k;$i++){
echo "<tr><td>";
echo "<a href="javascript:showdetail('detail.php?id=".$result[$i][id]."')">".$result[$i][name]."</a>";
echo "</td></tr>";
}
}


//**********<结束函数定义,主程序体*************
//构造这个viewpage类,给出商品表及每页显示行数

$view=new TViewPage($WARE_TABLE,$PAGE_MAX_LINE);

?>

下面给出用到的一个js函数吧,很简单,就是打开一个新窗口:
<script>
function showdetail(str){
window.open(str,"newwin","top=20,left=20,width=600,height=400,
location=no,toolbar=no,status=no,resizable=no,scrollbars=yes");
}
</script>



关键词:在线竞拍系统的PHP完成框架(一)




Copyright © 2012-2018 盾怪网教程(http://www.dunguai.com) .All Rights Reserved 网站地图 友情链接

免责声明:本站资源均来自互联网收集 如有侵犯到您利益的地方请及时联系管理删除,敬请见谅!

QQ:1006262270   邮箱:kfyvi376850063@126.com   手机版