Student Of Fortune

Reading And Displaying File Content DBF In PHP

Share on :
PHP is a popular programming language now supports reading and writing DBF files (dBase). PHP has a set of special functions related to the handling of dBase. In order to use these functions, the PHP libraries like php_dbase.dll (in Windows) should be activated. But in this tutorial we will not use dBase related functions, but we will use one library (class) that I can from a collection site php class. Library is named phpxbase and built by Erwin Kooi.
 
Reading And Displaying File Content DBF
To read the DBF files, use of library phpxbase XbaseTable class that we use. Here is a sample reading DBF files that have been made in the previous program. The data will be displayed in table form in the browser.

File Name: baca_dbf.php

<html>
<head> <title> List of Student Values (Demo Read DBF Files) </ title> </ head>
<body>
<h1> Student Value List </ h1>
<table width="100%" border="1">
<tr>
<th> NO </ th>
<th> NIM </ th>
<th> NAME </ th>
<th> VALUE </ th>
</ tr>

<? php

/ * load the required classes * /
require_once "phpxbase / Column.class.php";
require_once "phpxbase / Record.class.php";
require_once "phpxbase / Table.class.php";

/ * create object tables and open * /
$ table = new XBaseTable ("mahasiswa.dbf");
$ table-> open ();
$ row = 1;
while ($ record = $ table-> nextRecord ()) {
echo "<tr>";
echo "<td>". $ row ++."</ td> ";
foreach ($ table-> getColumns () as $ i => $ c) {
echo "<td>". $ record-> getString ($ c )."</ td> ";
}
echo "</ tr>";
} / / end while loop
$ table-> close ();
?>
</ table>
<p> <a href="tulis_dbf.php"> Added Values Student </ a> </ p>
</ body>
</ html>

1 comments:

Jaxon BP said... October 27, 2012 at 5:10 AM

Hmmm... I'm get this:

On line 15 I'm getting this:

Parse error: syntax error, unexpected T_REQUIRE_ONCE in...

Any ideas of what may be wrong?

Post a Comment and Don't Spam!

Dont Spam please

 
Recommended Post Slide Out For Blogger

Recent Comments

My Rank