版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、1基于基于 php 技术的电子商务技术的电子商务 web 数据库开发数据库开发目录目录摘要:摘要: .3关键字:关键字:.3一一.市场分析市场分析.3二二.网站制作思路网站制作思路.3三三.网站设计思想网站设计思想.3四四.内容框架内容框架.4五五.制作流程制作流程.5第一步 :安装环境.5第二步 :数据库的开发.6第三步 :配置的页面制作.10第四步 :后台页面的制作.11第五步 :前台页面的制作.15六六.调试发布调试发布.19七七.后期管理与维护后期管理与维护.19参考文献:参考文献:.192摘要:internet 的日益发展,使得电子商务倍受人们的关注,而企业网站做为电子商务的平台也越
2、来越受到企业的重视。在这里简单地分析了现在我国电子商务网站发展的现状并设计和建设了用 php 和 mysql 技术做成的网站,然后论述了该网站给企业带来的宣传效果及利润。关键字:internet;电子商务;php+mysql;网站建设一. 市场分析近年来,b2c 网站大量涌现,有许多企业网站不仅能够展示公司形象、产品信息,甚至可以实现在线购买产品,b2c 电子商务市场呈现出了“井喷”的势头,逐渐代替 c2c 市场,成为网购的一大主流,所以,企业建立自己的网站已经成为必然的趋势,在此之际,本公司建立了自己的独立网站,一方面方便网络客户更容易的找到本公司,另一方面开发网络客户。二. 网站制作思路网
3、站的组成部分包括网站的前台显示页面、后台控制页面和数据库三部分,在网站制作开始之前,首先要对数据库进行设计,如果数据库设计不好,整个网站的内容,不管是前台还是后台,都很难达到很好的连接,所以,数据库设计的合理与否关系到整个网站的牢固程度。在数据库建立好之后,接下来进行的就是网站的后台程序的开发,网站的后台程序是用来操作数据库的,后台程序的建立可以避免管理人员直接操作复杂的数据库而引起的错误,也避免了数据库数据的丢失或者其它的错误。网站前台的建设是用于显示数据库中的信息,把数据库中的数据通过直观的页面显示在浏览器中,让浏览者更清晰的看到公司的一些信息,是网站建设好坏的直接体现,所以前台页面的设计
4、一样很重要。在这三方面都建设完成之后,就基本上实现了网站的运营,即后台管理页面通过操作页面添加、删除、修改和更新数据库,通过数据库的更新,网站的前台页面也就随着更新,他们的关系如下图所示: 添加、删除、修改、更新 调用数据库调用数据库三. 网站设计思想整个网站的设计是基于 php5 语言的面向对象开发思想,其中包含少量的用于验证的javascript 脚本语言,另外一个重点就是运用 smarty 模板引擎来显示前台页面。在面向对象的开发过程中,把一些公用的函数、mysql 类或者一些配置文件放在一些固定的文件中,通过调用这些文件而实现功能,这样就减少了代码的书写;在开发前台的页面过程中通过使用
5、 smarty 模板可以通过调用 html 模板来实现 php 页面的显示,这样避免了每次修改页面的时候对代码的修改,使页面和代码实现分离,使操作更加简单。总得来说整个网站是使用的面向对象的开发思想,对页面的操作更加简单化,集成了面向对象开发的优点,对网站的后期管理和维护都有很多意想不到的好处。四. 内容框架整个网站由三大部分组成-前台、后台、数据库。后台前台数据库3数据库共由 11 个表组成,分别是:config(网站配置表) 、admin(管理员表) 、user(会员用户表) 、categories(商品分类表) 、products(商品信息表) 、cnewsclass(公司新闻分类表)
6、、cnewsbase(公司新闻基本表) 、cnewscontent(公司新闻内容表) 、company(公司简介表) 、guestbook(留言表) 、contact(联系方式表) 。后台页面根据需要总共有 16 个页面组成,分别是:管理员登陆页面(index.php) 、后台管理主页面(main.php) 、后台管理导航页面(admin_left.php) 、网站配置信息页面(admin_main.php)、公司介绍页面(admin_company.php),产品分类、产品列表、添加以及修改页面(admin_categories_class.php、admin_categories_list
7、.php、products_add.php、admin_categories_edit.php),公司新闻分类、新闻列表、添加以及修改页面(admin_news_class.php、admin_news_list.php、admin_news_add.php、admin_news_edit.php) ,留言列表展示以及查看留言页面(admin_guestbook.php、admin_guestbook_edit.php),联系方式页面(admin_contact.php)。另外还包括后台配置页面 config.php、admin_global.php 和 mysql 类的文件(action.c
8、lass.php 和 page.class.php) 。前台页面的设计:模板页面-index.html、aboutus.html、products.html、cnewsview.html、contact.html;images 文件夹;css 文件夹(css.css、css1.css) ;调用模板页面-index.php、aboutus.php、products.php、cnews.php、cnewsview.php、guest.php、contact.php、zhuce.php。底层结构图:4五. 制作流程第一步第一步 :安装环境:安装环境在整个网站开始制作之前要先安装用于本地调试的服务器,
9、在这里使用的是 wamp 包,该软件包含了 apache,mysql 和 php,是一个很好用的集成开发环境,安装完成之后启动服务器,在电脑的右下角出现如图所示的图标,点击后能够发现里面包含了 apache+mysql+php,其中localhost 是用于本地浏览文件的,phpmyadmin 是 mysql 的 web 操作客户端,可以看出,使用wamp 是很方便的。在开发环境安装好之后还需要安装一个编辑器,一个好的编辑器能够在编程方面起到很大的作用,在这里我使用的是 eclipse 编辑器,它能够实现边编辑边浏览的功能,而且能够起到代码提示的作用,还可以编辑除 php 文件之外的其它文件,
10、比如 html、css 等文件。其界面如图所示:5第二步第二步 :数据库的开发:数据库的开发数据库的开发:11 个数据库表的代码和结构如下:admin 表,这是用于管理管理员的表,其中包括 aid、m_id、aname、password、name 等字段,它的 sql 代码如下:create table graduatethesis.admin (aid int( 3 ) not null auto_increment primary key ,m_id int( 2 ) not null ,aname varchar( 25 ) character set gbk collate gbk_c
11、hinese_ci not null ,password varchar( 25 ) character set gbk collate gbk_chinese_ci not null ,name varchar( 50 ) character set gbk collate gbk_chinese_ci not null ) engine = myisam其结构如图所示:config 配置表是对公司网站的一些配置信息进行管理,包括 name、values、remark 字段,代码如下:create table graduatethesis.config (name varchar( 20 )
12、 character set gbk collate gbk_bin not null ,values varchar( 100 ) character set gbk collate gbk_bin not null ,remark text character set gbk collate gbk_bin not null ) engine = myisam其结构如图所示:user 表,用于存储会员注册的表格,包括:uid,uname,password, telephone,email,address 等字段,代码如下:create table graduatethesis.user (
13、uid int( 3 ) not null auto_increment primary key ,uname varchar( 20 ) character set gbk collate gbk_bin not null ,password varchar( 50 ) character set gbk collate gbk_bin not null ,telphone int( 12 ) not null ,email varchar( 20 ) character set gbk collate gbk_bin not 6null ,address varchar( 100 ) ch
14、aracter set gbk collate gbk_bin not null ) engine = myisam其结构如图所示:categories 表,用于存储产品的分类,包括 category_id,category_fid,category_name 等字段,其代码如下:create table graduatethesis.categories (category_id int( 5 ) not null auto_increment primary key ,category_fid int( 5 ) not null ,category_name varchar( 50 ) c
15、haracter set gbk collate gbk_bin not null ) engine = myisam其结构如图所示:products 表,用于存储产品的详细信息,包括 product_id,category_id,product_name,price,detail,photo,is_commend,post_datetime 等字段。其代码如下:create table ducts (product_id int( 10 ) not null auto_increment primary key ,category_id int( 5 )
16、not null ,product_name text character set gbk collate gbk_bin not null ,price float not null ,detail text character set gbk collate gbk_bin not null ,photo text character set gbk collate gbk_bin not null ,is_commend int( 11 ) not null ,post_datetime datetime not null ) engine = myisam其结构如图所示:7cnewsc
17、lass 表,用于存储新闻分类,包括如下字段:id,f_id,name,keyword,remark。其代码如下:create table ewsclass (id int( 11 ) not null auto_increment primary key ,f_id int( 11 ) not null ,name varchar( 25 ) character set gbk collate gbk_bin not null ,keyword varchar( 100 ) character set gbk collate gbk_bin not null ,remark varchar(
18、 100 ) character set gbk collate gbk_bin not null ) engine = myisam其结构如图所示:cnewsbase 表,用于存储新闻的基本信息,包括:id,cid,title,author,date_time 等字段。其代码如下:create table ewsbase (id int( 11 ) not null auto_increment primary key ,cid int( 11 ) not null ,title varchar( 50 ) character set gbk collate gbk_bin not null
19、 ,author varchar( 25 ) character set gbk collate gbk_bin not null ,date_time int( 10 ) not null ) engine = myisam其结构如图所示:cnewscontent 表,用于存储新闻的详细内容,包括:nid,keyword,content,remark 等字段。其代码如下:create table ewscontent (nid int( 11 ) not null ,keyword varchar( 100 ) character set gbk collate gbk_bin not nu
20、ll ,content text character set gbk collate gbk_bin not null ,remark text character set gbk collate gbk_bin not null ) engine = myisam其结构如图所示:8company 表,用于存储公司的基本信息,包括:name,values,remark 三个字段,其代码如下:create table pany (name varchar( 25 ) character set gbk collate gbk_bin not null ,values text character
21、 set gbk collate gbk_bin not null ,remark text character set gbk collate gbk_bin not null ) engine = myisam其结构如图所示:guestbook 表,用于存储用户的留言,包括:id,name,content,telphone,email,time 等字段。其代码如下:create table graduatethesis.guestbook (id int( 5 ) not null auto_increment primary key ,name text character set gb
22、k collate gbk_bin not null ,content text character set gbk collate gbk_bin not null ,telphone int( 12 ) not null ,email text character set gbk collate gbk_bin not null ,time datetime not null ) engine = myisam其结构如下:contact 表,用于存储公司的联系方式的表,包括:name,values,remark 等字段。其代码如下:create table graduatethesis.c
23、ontact (name varchar( 10 ) character set gbk collate gbk_bin not null ,values varchar( 100 ) character set gbk collate 9gbk_bin not null ,remark text character set gbk collate gbk_bin not null ) engine = myisam其结构如图所示:第三步第三步 :配置的页面制作:配置的页面制作配置页面的制作在页面配置的文件 config.php 中,包括了数据库的连接和 smarty 配置,其代码如下:在网站
24、的主配置页面完成之后,接下来进行数据库的连接,在后台的开发中,要进行 mysql的配置,在 admin_global.php 文件中完成数据库和后台的连接,代码如下:在这里需要引入的有四个文件,即 mysql.class.php,config.php,10page.class.php 和 action.class.php。其中 mysql.class.php 文件是在操作数据库过程中面向对象的一个必不可少的文件;page.class.php 是定义了分页原理,实现后台某些页面的分页;action.class.php 文件是在文件提交之后的一些跳转页面。在网站的前台配置页面中一样也需要这些页面,
25、但是,前台的配置还包含了 smarty 的配置,smarty 的配置很简单,只需要将下载好的 smarty 引擎的主要部分拷贝到该项目中就行了。第四步第四步 :后台页面的制作:后台页面的制作后台页面的制作:在制作后台的管理页面时,首先制作好一些导航页面,包括:index.php(登陆界面) ,admin_left.php(左侧导航)main.php(主显示页面) 。在公司介绍页面中(admin_company.php)运用到了数据库的查询与更新其中调用数据的 sql 语句:if($_getaction=logout)$db-get_user_out();$query=$db-findall(c
26、ompany);while($row=$db-fetch_array($query)$row_arr$rowname=$rowvalues;更新数据的 sql 语句:if($_getaction=logout)$db-get_user_out();$query=$db-findall(company);while($row=$db-fetch_array($query)$row_arr$rowname=$rowvalues;在后台的页面制作中有一个很重要的页面就是产品添加页面(products_add.php) ,在这个页面中需要上传照片,而且需要判断填写的信息是否详细,这里使用了 javas
27、cript 脚本来判断,其代码如下:function synctextarea()if(upform.cid.value=0)alert(请选择分类);return false;if(duct_name.value=)alert(请填写产品名称);duct_name.focus();return false;if(upform.price.value=)alert(请填写产品价格);upform.price.focus();return false;if(upform.detail.value=)alert(请填写详细信息);11upform.detai
28、l.focus();return false;在上传照片的代码中,首先将 input 框的 type 格式改写成 file 格式,然后就是对上传图片的处理,代码如下:if (is_uploaded_file($_filesupfiletmp_name)$upfile=$_filesupfile;$name = $upfilename;$type = $upfiletype;$size = $upfilesize;$tmp_name = $upfiletmp_name;$error = $upfileerror;switch ($type) case image/pjpeg : $ok=1;br
29、eak;case image/jpeg : $ok=1;break;case image/gif : $ok=1;break;case image/png : $ok=1;break;move_uploaded_file($tmp_name,uploads/.$name);在添加产品的时候需要选择分类,这里需要从数据库中调用产品分类并显示在下拉选项框中,其实现代码如下:?php$query=mysql_query(select * from categories where category_fid=0);while ($row=mysql_fetch_array($query) echo$r
30、owcategory_name;$query_son=mysql_query(select * from categories where category_fid=$rowcategory_id);while ($row_son=mysql_fetch_array($query_son) echo $row_soncategory_name;?在点击提交按钮时,进行数据库的操作,实现代码:12if(isset($_postinto_products)$db-query(insert into products (product_id, category_i
31、d, product_name, price, detail, photo, is_commend, post_datetime) .values (null, $_postcid, $_postproduct_name, $_postprice, $_postdetail, $name, $_postis_commend, now();$db-get_admin_msg(admin_categories_list.php,添加成功);产品分类页面:实现的功能是添加产品大类,小类以及更新分类和删除分类。添加分类的实现代码:findall(categories where category_fi
32、d=0);while ($row=$db-fetch_array($query) $news_class_arr$rowcategory_id=$rowcategory_name;echo $rowcategory_name;?添加分类:if(isset($_postinto_class)$db-query(insert into graduatethesis.categories (category_id, category_fid, category_name) . values (null, $_postf_id, $_postname);$db-get_admin_msg(admin_
33、categories_class.php,已经成功添加分类);删除分类:if(!empty($_getdel)$db-query(delete from categories where category_id = $_getdel limit 1;);$db-get_admin_msg(admin_categories_class.php,删除成功);更新分类:if(isset($_postupdate_class)$db-query(update categories set category_name=$_postname where category_id = $_postid lim
34、it 1;);$db-get_admin_msg(admin_categories_class.php,更新成功);产品的编辑页面和添加产品的页面类似,只是将添加产品的 sql 语句中的 insert 语句改写成update 语句;产品列表显示页面需要将所有的产品基本信息显示出来,其中用到了分页原理,其代码如下:产品分类产品名称价格图片详细信息操作?php$result = mysql_query(select product_id from products);$total = mysql_num_rows($result);pageft($total, 20);if ($firstcoun
35、t findall(products limit $firstcount, $displaypg);while ($row = $db-fetch_array($query) ?a href=?del=删除 / a href=admin_categories_edit.php?id=修改公司新闻页面的分类,添加,修改和显示都和产品编辑页面类似,这里就不一一的描述了。留言列表的显示:首先从数据库中调用留言数据,然后显示在后台页面中,其实现代码如下:$query=$db-findall(guestbook);while ($row=$db-fetch_array($query) $news_cla
36、ss_arr$rowid=$rowname;其中有嵌入分页原理,其代码和产品列表和新闻列表的分页原理的代码一样。公司的联系方式页面是从 contact 表中调用数据的,然后显示在页面中,管理员可以进行修改:其代码是:if($_getaction=logout)$db-get_user_out();$query=$db-findall(contact);while($row=$db-fetch_array($query)$row_arr$rowname=$rowvalues;if(isset($_postupdate)unset($_postupdate);foreach($_post as $
37、name=$values)$db-query(update contact set values=$values where name=$name);$db-get_admin_msg(admin_contact.php);14到此,后台页面的制作基本完成,在调试无误后,接下来进行的是网站前台页面的制作。第五步第五步 :前台页面的制作:前台页面的制作前台页面的制作:在网站进行 smarty 引擎的引用是,首先对 smarty 进行配置,在 global.php 文件中进行配置,其代码如下:template_dir= $smarty_template_dir;$smarty-compile_di
38、r= $smarty_compile_dir;$smarty-config_dir= $smarty_config_dir;$smarty-cache_dir= $smarty_cache_dir;$smarty-caching= $smarty_caching;$smarty-left_delimiter = $smarty_delimiter0;$smarty-right_delimiter= $smarty_delimiter1;$smarty-assign(t_dir,$smarty_template_dir);?接下来需要设计一些网站的模板,这里我使用了 dreamweaver 软件
39、来设计网站的模板,这里引入了五个 html 文件的模板,首先是对 index.html 文件的引入,在 index.php 文件中可以用以下代码实现 index.html 模板的引入:query(select * from config);$row=$db-fetch_array($query);while($row_config=$db-fetch_array($query)$sm_config=$row_configvalues;$smarty-assign(sm_config,$sm_config);/配置引入$smarty-display(index.html);?这样就把网站的配置信
40、息给引入到 smarty 模板引擎中了,然后再 index.html 文件中把相应的位置替换以下就行了,如:15$sm_config1这里的$smarty_config是一种数组形式的数据,在调用中只需要讲数组中的键值指出就能显示内容了。为了体现面向对象的开发思想,我把所有的数据库的引入代码全部写入 smarty.php 文件中,然后通过调用 smarty.php 文件来实现相同的功能,这样,修改和维护都更方便一些。以下是 smarty.php 文件的代码:query(select * from config);$row=$db-fetch_array($query);while($row_c
41、onfig=$db-fetch_array($query)$sm_config=$row_configvalues;$smarty-assign(sm_config,$sm_config);/配置引入$sql=select * from categories where category_fid=0;$query=$db-query($sql);while($row_categories=$db-fetch_array($query)$sm_categories=array(category_name=$row_categoriescategory_name,category_id=$row_
42、categoriescategory_id);$smarty-assign(sm_categories,$sm_categories);/产品分类引入$sql=select * from products where is_commend=1;$query=$db-query($sql);while($row_products=$db-fetch_array($query)$sm_products=array(product_name=$row_productsproduct_name,product_id=$row_productsproduct_id,price=$row_products
43、price,photo=$row_productsphoto,detail=$row_productsdetail);$smarty-assign(sm_products,$sm_products);/推荐产品引入$sql=select * from products where is_commend=0;$query=$db-query($sql);while($row_product=$db-fetch_array($query)$sm_product=array(product_name=$row_productproduct_name,product_id=$row_productpr
44、oduct_id,price=$row_productprice,photo=$row_productphoto,detail=$row_productdetail);$smarty-assign(sm_product,$sm_product);/不是推荐产品的引入$sql=select * from products;$query=$db-query($sql);while($row_productss=$db-fetch_array($query)16$sm_productss=array(product_name=$row_productssproduct_name,product_id
45、=$row_productssproduct_id,price=$row_productssprice,photo=$row_productssphoto,detail=$row_productssdetail);$smarty-assign(sm_productss,$sm_productss);/产品的引入$sql=select * from cnewsbase;$query=$db-query($sql);while($row_cnewsbase=$db-fetch_array($query)$sm_cnewsbase=array(title=$row_cnewsbasetitle,au
46、thor=$row_cnewsbaseauthor,date_time=$row_cnewsbasedate_time);$smarty-assign(sm_cnewsbase,$sm_cnewsbase);/公司新闻列表引入/=if(!empty($_getid)$sql=select * from cnewsbase as a, cnewscontent as b where a.id=b.nid and a.id=$_getid;$query=mysql_query($sql);$row_news=mysql_fetch_array($query);$row_news4=date($ro
47、w_news4);$smarty-assign(row_news,$row_news);/公司新闻内容的引入$sql=select * from contact;$query=$db-query($sql);while($row_contact=$db-fetch_array($query)$sm_contact=$row_contactvalues;$smarty-assign(sm_contact,$sm_contact);/联系方式引入$db-query(select * from company);$row=$db-fetch_array($query);while($row_company=$db-fetch_array($query)$sm_company=$row_companyva
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 26年非霍奇金淋巴瘤基因检测实操
- 口才教育教案
- 教育技术发展与应用概述
- 文化商业空间设计
- 工作检讨流程
- 少儿茶之源启蒙文化课
- 健康护理教育
- 2026儿科水痘护理查房解读
- 民宿设计策略
- 风湿免疫科硬皮病皮肤护理建议
- 混凝土日常安全培训资料课件
- DB61T 926-2014 火灾高危单位消防安全管理与评估规范
- 腹腔镜食管裂孔疝修补术七步法 2025解读
- 2024-2025学年广东省广州市海珠区六年级下册期末语文检测试题(部编版)附答案
- 港口防台风安全知识培训课件
- 山东科技大学《概率论与数理统计》2024-2025学年第一学期期末试卷
- GB/T 755-2025旋转电机定额与性能
- 贵州省六盘水市2024-2025学年高一下学期期末质量监测物理试卷(PDF版无答案)
- 银行案件防控培训资料
- 智联招聘测评题库及答案
- 物业sop管理制度
评论
0/150
提交评论