Make a database driven website in 3 steps

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.

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.

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.

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.

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:

ID as number data type which will be our primary key also.
Name as text data type
Publisher as text data type
PublishYear as text data type

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.

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.

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.


Open in new window

[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.

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.

                      <title>Simple DB report page</title>
                      <tr><th>ID</th><th>Name</th><th>Publisher</th><th>Publish Year</th></tr>
                      <div align='center'>$wbnavigator</div>

Open in new window

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.

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.

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.

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.

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.

                      <title>Search filter file</title>
                      <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' />

Open in new window

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.

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».

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.

For more information about WhizBase or to download it for free you can visit To learn more, contact me at 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.

Comments (0)

Have a question about something in this article? You can receive help directly from the article author. Sign up for a free trial to get started.