In this tutorial I will show you how to provide a dynamic RTF document on your website generated with data from your database. For this tutorial you will need Microsoft Word or WordPad, WhizBase and Microsoft Access.
Create your document First you need to make an RTF template, it is how the document will look like. I have created a file which lists the first name, last name, telephone, email and address in a table.
As you can see the dynamic part will contain WhizBase code. I have putted $wbf[fname], $wbf[lname], $wbf[email], $wbf[tel] and $wbf[address] in the cells I want to show dynamic data.
These placeholders will be replaced dynamically with data.
Now just save the document as RTF file. You go to "Save As" and save the file as "form.rtf".
Create you database file
The database can be in any format, I will use Microsoft Access because it is the easiest for me. You can use MySQL, Oracle, MS SQL or even Microsoft Excel.
I will create a database file with one table "contacts", it will contain these 6 fields:
ID – autonumaber and primary keyFname – textLname – textEmail – textTel – textAddress – memo
Now save this file as "form.mdb"
I have inserted some records in this table.
Create WhizBase file Finally we need a file which will be our webpage which takes the ID and gives us the RTF document. So we need to implement an input form for ID, and when submit is clicked then start downloading the new generated file.
First let's rename the file "form.rtf" to "form.ic", "ic" is the extension for included files in WhizBase by the function $wbrinc.
This is a very basic HTML form file, the only thing you must not forget is the name of the text field, it will be wbf_id, which I have already explained in previous tutorials. Save this file as "default.wbsp".
Now we create another WhizBase file where we query the DB and include the RTF template file.