Mar 17, 2011

You just finished building the perfect database for use as a web-app, if only you knew how to write a web-app
What do you do?

Well, writing a web application does not have to be complicated and definitely does not have to take months of programming. With WhizBase it takes just two steps to make your database "airborne".

Step one - create report that will display records from your database
Open your ordinary, plain HTML web page, position your cursor where you want
your records displayed and type the following code (replace values for
WB_BaseName and WB_RcdSet with your own values):

#*
[FormFields]
wb_basename=biblio.mdb
wb_rcdset=(Authors inner join titles on authors.au_id=titles.au_id) inner join
publishers on publishers.pubid=titles.pubid
wb_command=q
*#
#*Now we will add some plain HTML with no WhizBase code*#
<table border="1" cellpadding="3" cellspacing="0">
<tr>
<td>Title</td>
<td>Year published</td>
<td>ISBN</td>
<td>Author</td>
<td>Publisher</td>
</tr>
#*And here we will start adding some really simple WhizBase code*#
<!--WB_BeginDetail-->#*Define the beginning of block that will be repeated for every record*#
<tr>

<td>$wbf[Title]</td>
<td>$wbf[Year published]</td>
<td>$wbf[ISBN]</td>
#*Since we have field "Name" in two joined tables we must add table name in $WBF function together with the name of the field*#
<td>$wbf[Authors.name]</td>
<td>$wbf[Publishers.name]</td>
</tr>
<!--WB_EndDetail-->#*Define the end of repeating block *#
</table>
$wbnavigator[]

Save it as books.wbsp and the report is finished.

Step two - create search form

The search form for this example will be ordinary page with HTML form as follows:

<form action="books.wbsp" method="POST">
<table border="1" cellpadding="3" cellspacing="0">
<tr>
<td>Title</td>
<td><input type="text" name="WBF_Title" value=""></td>
</tr>
<tr>
<td>Year Published</td>
<td><input type="text" name="WBF_Year Published" value=""></td>
</tr>
<tr>
<td>ISBN</td>
<td><input type="text" name="WBF_ISBN" value=""></td>
</tr>
<tr>
<td>Search conditions</td>
<td ><select size='1' name='wb_andor'>
<option value='And'>all conditions</option>
<option value='Or'>any condition</option>
</select></td>
</tr>
</table>
<input type='submit' value='Search'>
<input type='reset' value='Reset'>
</form>

As you can see, there's nothing special with this form except that we named input text fields same as database fields with prefix (WBF_). When user submits the form data to books.wbsp (report we created earlier) WhizBase opens database biblio.mdb, create recordset based upon WB_RcdSet value combined with WHERE clause generated from form fields WBF_Title, WBF_Year published, WBF_ISBN. Upon creating recordset, WhizBase "reads" the report, search for detail section (everything between <!--WB_BeginDetail--> and <!--WB_EndDetail-->), finds the keywords (in this case $wbf[] functions) processes them and send to the browser, and repeats it for 20 records. After that, it process $WBNavigator[] function and generate links to other report pages (paginate the report).
Of course, you can format HTML form and WhizBase report anyway you want using ordinary HTML or CSS.

More info: http://www.whizbase.com/

1 comment:

Computer articles said...

Thanks for share tutorial and script about building the database for use as a web-app