how to retrieve data from multiple dbf files in php?

  • Thread starter Thread starter Me : )
  • Start date Start date
i got this code over the internet, using this, code, i want to open another dbf file and retrieve its data in sync with the first-opened dbf file...how can i implement this...
<?php
# Constants for dbf field types
define ('BOOLEAN_FIELD', 'L');
define ('CHARACTER_FIELD', 'C');
define ('DATE_FIELD', 'D');
define ('NUMBER_FIELD', 'N');

# Constants for dbf file open modes
define ('READ_ONLY', '0');
define ('WRITE_ONLY', '1');
define ('READ_WRITE', '2');

# Path to dbf file
$db_file = 'LAST/CIF.DBF';

# dbf database definition
# Each element in the first level of the array represents a row
# Each array stored in the various elements represent the properties for the row
$dbase_definition = array (
array ('name', CHARACTER_FIELD, 20), # string
array ('date', DATE_FIELD), # date yyymmdd
array ('desc', CHARACTER_FIELD, 45), # string
array ('cost', NUMBER_FIELD, 5, 2), # number (length, precision)
array ('good?', BOOLEAN_FIELD) # boolean
);


# open dbf file for reading and writing
$id = @ dbase_open ($db_file, READ_WRITE)
or die ("Could not open dbf file <i>$db_file</i>.");

$num_fields = dbase_numfields ($id);
$num_rows = dbase_numrecords($id);

print "dbf file <i>$db_file</i> contains $num_rows row(s) with $num_fields field(s) in each row.\n";

# Loop through the entries in the dbf file
for ($i=1; $i <= $num_rows; $i++) {
print "\nRow $i of the database contains this information:<blockquote>";
print_r($data=(dbase_get_record_with_names ($id,$i)));
print "</blockquote>";
}


# close the dbf file
dbase_close($id);
?>
 
Back
Top