第三方库构建步骤_通过3个步骤构建数据库驱动的网站

第三方库构建步骤

Today every company has to have a website, it is a business necessity, like having a telephone number or a company address. However, a lot of companies do not have a budget for an elaborate, database-driven website, they think it is very expensive, and they are right. If you use a web developer in Europe you will need a couple of thousands of Euros to make a simple website to present your company.

如今,每个公司都必须拥有一个网站,这是一项业务必需品,就像拥有电话号码或公司地址一样。 但是,许多公司没有预算来建立一个精致的,数据库驱动的网站,他们认为这是非常昂贵的,而且他们是对的。 如果您在欧洲使用Web开发人员,则需要花费几千欧元才能制作一个简单的网站来介绍您的公司。

In this article I will give a simple tutorial how to publish your database report without the need for a web-developer, something simple but yet very powerful, with your Microsoft access database.

在本文中,我将提供一个简单的教程,说明如何使用Microsoft Access数据库在不需要Web开发人员的情况下发布数据库报告,这是一个简单但功能非常强大的操作。

This method is best way for web designers, who know how to make a web page in HTML, but do not know how to connect it with the database, without using PHP or ASP.

这种方法是Web设计人员的最佳方法,他们知道如何用HTML制作网页,却不知道如何将其与数据库连接,而不使用PHP或ASP。

First step: create your report page

第一步:创建报告页面

To show your report online, you will need a database access file and a HTML file which will show the report or the query results.

要在线显示报告,您将需要一个数据库访问文件和一个HTML文件来显示报告或查询结果。

We will create the database in Microsoft access, I will create a database and name it as biblio and create a table and name it Titles, we will make these fields:

我们将在Microsoft Access中创建数据库,创建数据库并将其命名为biblio,并创建表并将其命名为Titles,我们将创建以下字段:

ID as number data type which will be our primary key also.

ID为数字数据类型,这也是我们的主键。

Name as text data type

名称为文本数据类型

Publisher as text data type

发布者为文本数据类型

PublishYear as text data type

PublishYear作为文本数据类型

I will fill it with some data and save it, and we have a database file.

我将用一些数据填充并保存它,并且我们有一个数据库文件。

If you have a design for your report you will need to slice it and make a HTML page, you can use GIMP on linux or Photoshop on windows, then use any HTML editor or text editor to make the HTML code.

如果您有报告的设计,则需要对其进行切片并制作HTML页面,可以在Linux上使用GIMP或在Windows上使用Photoshop,然后使用任何HTML编辑器或文本编辑器来制作HTML代码。

I will use a simple example using WhizBase Server Pages (WBSP) to develop this report. WBSP is a very powerful tool for publishing databases online with a very simple code, it is not like classic web programming languages.

我将使用一个使用WhizBase服务器页面(WBSP)的简单示例来开发此报告。 WBSP是使用非常简单的代码在线发布数据库的功能非常强大的工具,它不像经典的Web编程语言。

Create the header:

创建标题:

Every WBSP page have a header, it is a place where we put some information needed by the server, everything we write in this section will not appear in our page. This section contains the variables that are essential for processing WBSP file. Here you put information about the database, recordset, template, error template, log file, redirection, etc. We will simply say for the server to connect to our access database and select a table, list for example 10 records only and make a pagination.

每个WBSP页面都有一个页眉,在这里放置服务器所需的一些信息,本节中编写的所有内容都不会出现在页面中。 本节包含对于处理WBSP文件必不可少的变量。 在这里,您可以放置​​有关数据库,记录集,模板,错误模板,日志文件,重定向等的信息。我们只需要说服服务器连接到我们的访问数据库并选择一个表即可,例如仅列出10条记录并进行分页。

 [FormFields]
 wb_basename=biblio.mdb
 wb_rcdset=Titles
 WB_Command=Q
 WB_MaxRec=10
 <!--WB_BeginTemplate-->

[FormFields] is the starting tag for the section, when the server sees this code it will start receiving our commands. wb_basename=biblio.mdb is our database file, I have putted our database in the same folder as my HTML file so I am calling it directly. The server will look for the file name what ever we give as a path for it after wb_basename and connect to the database file. To specify which table we will select we use wb_rcdset=Titles, as you see I will select the table Titles. We told the server which database file to connect and which table to select, now we need to tell it what to do, and in our case is query, using the command WB_Command we give it a value Q and we did it. Finally we want to limit our results, let us show 10 records by page. We can skip this line and it will list the whole table, but what if we have a table with 10 000 records or more, do you really want to show it all in one page? So we will use WB_MaxRec=10 and that is all what we need. Now give the server a simple comment like command <!--WB_BeginTemplate--> which says to the server begin interpreting the template.

[FormFields]是该部分的开始标记,当服务器看到此代码时,它将开始接收我们的命令。 wb_basename = biblio.mdb是我们的数据库文件,我已经将数据库与HTML文件放在同一文件夹中,所以我直接调用它。 服务器将在wb_basename之后查找我们提供的文件名作为其路径,然后连接到数据库文件。 要指定要选择的表,我们使用wb_rcdset = Titles,如您所见,我将选择表Titles。 我们告诉服务器要连接的数据库文件和要选择的表,现在我们需要告诉它要做什么,在我们的例子中是查询,使用命令WB_Command我们给它一个值Q,然后就完成了。 最后,我们要限制结果,让我们按页面显示10条记录。 我们可以跳过这一行,它将列出整个表,但是如果我们有一个包含10 000条或更多记录的表,您真的要在一个页面中全部显示吗? 因此,我们将使用WB_MaxRec = 10,这就是我们所需要的。 现在给服务器一个简单的注释,例如命令<!-WB_BeginTemplate->,它对服务器说开始解释模板。

Create the body (template):

创建主体(模板):

After creating the header section we have to create the template, and that is very simple, it is our HTML code with simple lines of WBSP code where we want to show our data.

创建标头部分之后,我们必须创建模板,这非常简单,这是我们HTML代码和WBSP代码的简单行,我们希望在其中显示数据。

<html>
<head>
<title>Simple DB report page</title>
</head>
<body>
<table>
<tr><th>ID</th><th>Name</th><th>Publisher</th><th>Publish Year</th></tr>
<!--WB_BeginDetail-->
<tr><td>$wbf[ID]</td><td>$wbf[Name]</td><td>$wbf[Publisher]</td><td>$wbf[PublishYear]</td></tr>
<!--WB_EndDetail-->
</table>
<div align='center'>$wbnavigator</div>
</body>
</html>

In the template we want to view ten records in a table and then show the navigation bar where users can go to the next or previous page to see more records.

在模板中,我们要查看一个表中的十个记录,然后显示导航栏,用户可以在其中导航到下一页或上一页来查看更多记录。

The most important code in this template is <!--WB_BeginDetail--> and <!--WB_EndDetail--> which represents the start and the end of the looping function, everything between these two will loop for as many times as records we want to show. If the query returned 10 records it will loop for ten times. Between these two commands we will show the records using the function $wbf[fieldname], in our case we are viewing four fields in the table and WBSP will replace every one with the field value in the table.

此模板中最重要的代码是<!-WB_BeginDetail->和<!-WB_EndDetail->,它们代表循环功能的开始和结束,这两者之间的所有循环将循环我们记录的次数想展示。 如果查询返回10条记录,它将循环十次。 在这两个命令之间,我们将使用函数$ wbf [fieldname]显示记录,在本例中,我们正在查看表中的四个字段,WBSP将用表中的字段值替换每个字段。

Finally we have $wbnavigator which will generate for us the navigation links automatically, this is a very cool command, we do not need to calculate anything, it will automatically create as many pages as we need.

最后,我们有$ wbnavigator,它将为我们自动生成导航链接,这是一个非常酷的命令,我们不需要计算任何内容,它将自动创建所需的页面。

We will save all this as defaut.wbsp file, where the extension wbsp will tell the server that this file have a WBSP code in it.

我们将所有这些都保存为defaut.wbsp文件,其中扩展名wbsp将告诉服务器该文件中包含WBSP代码。

Second step: Create a search form

第二步:创建搜索表单

In the previous step we have made a report page, now we need a filtering form, for example what if we do not want to view all the records, we want to view just records for the publish year 2007.

在上一步中,我们创建了一个报告页面,现在我们需要一个过滤表单,例如,如果我们不想查看所有记录,而只想查看2007年发布的记录,该怎么办?

Create a file named as «search.htm», in this file we will not need any WBSP code, we will only make a HTML form with inputs and a submit. We only must take into account one thing, how we will name our inputs, because WBSP have its automatic mechanism for catching get and post values.

创建一个名为“ search.htm”的文件,在该文件中,我们不需要任何WBSP代码,我们将仅创建带有输入和提交HTML表单。 我们仅需考虑一件事,即我们如何命名输入,因为WBSP具有自动获取和发布值的机制。

<html>
<head>
<title>Search filter file</title>
</head>
<body>
<form action='default.wbsp' method='post'>
ID <input type='text' name='wbf_id' /><br />
Name <input type='text' name='wbf_name' /><br />
Publisher <input type='text' name='wbf_publisher' /><br />
Publish Year <input type='text' name='wbf_publishyear' /><br />
<input type='submit' value='submit' />
</form>
</body>
</html> 

As you can see we have used a pure HTML, but we have also used a specific naming method in the input names. WBF_ID is WBF_ + ID where WBF_ is WhizBase prefix and ID is the name of the table field. WhizBase catches all the get and post data and filters them, then takes all the post and get data with prefix WBF_ and sends them to the query.

如您所见,我们使用了纯HTML,但在输入名称中也使用了特定的命名方法。 WBF_ID是WBF_ + ID,其中WBF_是WhizBase前缀,ID是表字段的名称。 WhizBase捕获所有获取和发布数据并对其进行过滤,然后获取所有发布并获取带有前缀WBF_的数据,并将其发送到查询。

For example if we put a value 2000 in «Publisher Year» input, it will be a post value in the variable wbf_publisheryear, WhizBase will filter it and catch it because it has wbf_ prefix and then send it as a database query as «publisheryear = 2000».

例如,如果我们在«Publisher Year»输入中输入值2000,它将是变量wbf_publisheryear中的post值,WhizBase将对其进行过滤并捕获它,因为它具有wbf_前缀,然后将其作为数据库查询发送为«publisheryear = 2000»。

Third Step: Upload everything online

第三步:在线上传所有内容

Finally, we have a form file, a report file and a database. We do not need anything else. Now just upload the 3 files online in the same folder on a server which supports Whizbase or install Whizbase on your Windows server and put these files on the server and you will have a ready report and a filtering system.

最后,我们有一个表单文件,一个报告文件和一个数据库。 我们不需要任何其他东西。 现在,只需将这3个文件在线上载到支持Whizbase的服务器上的同一文件夹中,或在Windows服务器上安装Whizbase并将这些文件放在服务器上,便会准备好报告和筛选系统。

For more information about WhizBase or to download it for free you can visit http://www.whizbase.com. To learn more, contact me at NURAZIJE [at] GMAIL [dot] COM

有关WhizBase的更多信息或免费下载,可以访问http://www.whizbase.com 。 要了解更多信息,请通过NURAZIJE与我联系[at] GMAIL [dot] COM

NurAzije is a PHP and WhizBase programmer, who at the time of article publication is working in partnership with WhizBase on several projects.

翻译自: https://www.experts-exchange.com/articles/1882/Make-a-database-driven-website-in-3-steps.html

第三方库构建步骤

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值