Jun 3, 2009

Make a database driven website in 3 steps

Today every company had to have a website, it is something like having a telephone number or a company address. A lot of companies do not have yet a budget for making a 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 databse 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 programing 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 apear 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 pagiation.



1 [FormFields]

2 wb_basename=biblio.mdb

3 wb_rcdset=Titles

4 WB_Command=Q

5 WB_MaxRec=10

6 <!--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.


Create the body (template):


After creating the header setion 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>

<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 next or previus 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 say to 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.




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



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 http://www.whizbase.com

5 comments:

Unknown said...


Trung niên phụ nhân nói xong, một thanh kiếm xanh biếc đã xuất hiện ở trong tay của nàng, thân hình lao tới, thẳng hướng về phía Hỗn Thế Ma Vương mà công kích.

- Thủy Thanh, chỉ bằng vào ngươi mà muốn đối phó với ta sao, thực lực của ta cho dù chưa khôi phục nhưng cũng đủ để thu phục ngươi.

Hỗn Thế Ma Vương nhẹ nhàng nói, hai tay của hắn xuất thủ, một thanh trường kiếm màu đen xuất hiện, mười đạo kiếm khí bén nhọn bắn ra, ngăn cản kiếm quang công kích của trung niên phụ nhân. “Xoẹt xoẹt xoẹt” Hai người giao thủ mấy lần, thân thể của phụ nhân kia đã bị ngăn cản, xem ra đã rơi vào thế hạ phong.
dongtam
game mu
cho thue phong tro
http://nhatroso.com/
nhac san cuc manh
tổng đài tư vấn luật
http://dichvu.tuvanphapluattructuyen.com/
văn phòng luật
tổng đài tư vấn pháp luật
thành lập công ty
http://we-cooking.com/
chém gió
trung tâm ngoại ngữ
- Ta đã nói rồi ngươi không phải là đối thủ của ta.

Hỗn Thế Ma Vương không hề dừng lại, tung người xuống lần nữa hướng về phía vô tận thủy vực bay đi, ma khí nồng nặc đuổi theo phụ nhân áo lục.

- Hỗn Thế Ma Vương, ngươi đừng tưởng là có thể bắt ta, Thủy Tuyệt kiếm trận.

Phụ nhân áo lục lạnh lùng nói, nhìn thấy Hỗn Thế Ma Vương đánh về phía mình, thủ

Janu said...

Its a wonderful post and very helpful, thanks for all this information. You are including better information regarding this topic in an effective way



Dot Net Training in Chennai | Dot Net Training in anna nagar | Dot Net Training in omr | Dot Net Training in porur | Dot Net Training in tambaram | Dot Net Training in velachery








Maradona Jons said...

With special privileges and services, UEFA BET offers opportunities for small capitalists. Together ufa with the best websites that collect the most games With a minimum deposit starting from just 100 baht, you are ready to enjoy the fun with a complete range of betting that is available within the website

ufabet , our one another option We are a direct website, not through an agent, where customers can have great confidence without deception The best of online betting sites is that our Ufa will give you the best price

หาคุณกำลังหาเกมส์ออนไลน์ที่สามารถสร้างรายได้ให้กับคุณ เรามีเกมส์แนะนำ เกมยิงปลา รูปแบบใหม่เล่นง่ายบนมือถือ คาสิโนออนไลน์ บนคอม เล่นได้ทุกอุปกรณ์รองรับทุกเครื่องมือ มีให้เลือกเล่นหลายเกมส์ เล่นได้ทั่วโลกเพราะนี้คือเกมส์ออนไลน์แบบใหม่ เกมยิงปลา

อีกทั้งเรายังให้บริการ เกมสล็อต ยิงปลา แทงบอลออนไลน์ รองรับทุกการใช้งานในอุปกรณ์ต่าง ๆ HTML5 คอมพิวเตอร์ แท็บเล็ต สมาทโฟน คาสิโนออนไลน์ และมือถือทุกรุ่น เล่นได้ตลอด 24ชม. ไม่ต้อง Downloads เกมส์ให้ยุ่งยาก ด้วยระบบที่เสถียรที่สุดในประเทศไทย

Maradona Jons said...

By far the most real football betting UFABET that's beyond description Find fun, excitement and excitement with slot games, 100 totally free credit, rapid withdrawal. If you want to play slots for cash No need to have to deposit a good deal, without bare minimum, without need to have to discuss, throw away moment because UFABET is in fact broken off, paid seriously, a number of excellent offers are awaiting you. Ready to assure enjoyable, no matter if it's Joker SlotXo fruit slot, we can telephone call it a web slot internet site for you especially. Ready to play Including the assistance team which is going to facilitate slot formulas plus methods of actively playing So you will be sure that every minute of fun and excitement We will be there for you to give your customers the best impact along with achievement.
บาคาร่า
สล็อต
ufa
แทงบอล

Howell Daniel said...

For any influential executive today, security is one of the most important topics. Today, executive bodyguard company
protection is one of the most profitable services offered with so much fear globally. Every citizen in the world is now examining Executive Security to do their ordinary jobs without disrupting anybody waiting for any harm.