filepro_retrieveDescriptionfilepro_retrieve() fetches an individual record from a FilePro database. The function accepts two arguments: a row offset and a field offset. By using this function with the filepro_fieldcount() and filepro_rowcount() functions, you can traverse the entire database. If the specified offsets are outside the valid range or if another error occurs, the function returns FALSE and generates a warning-level error. ExampleExample 296. Traverse an entire database and display the results in a formatted text table <pre> <?php $fp_db = 'c:\fp\filepro\fpcust'; // Select the FilePro database @ filepro ($fp_db) or die ("The '$fp_db' directory does not seem to contain a FilePro database map file. Please check the directory path, along with the directory and file permissions."); $field_count = filepro_fieldcount (); $row_count = filepro_rowcount (); // Print the top of the table $line .= '| '; for ($field_offset=0; $field_offset < $field_count; $field_offset++) { $width = filepro_fieldwidth ($field_offset); $name = filepro_fieldname ($field_offset); $line .= sprintf ('<b>%-'.$width.'s</b> | ', $name); // Handle cases where the length of the field name is greater than the field length $field_width[$field_offset] = ($width < strlen ($name) ? strlen ($name) : $width); } // Make a separator for the table header $separator = str_repeat ('-', strlen (strip_tags ($line)) - 1); echo $separator, "\n", $line, "\n", $separator; // Show all the records in the database for ($row_offset=0; $row_offset < $row_count; $row_offset++) { print "\n| "; for ($field_offset=0; $field_offset < $field_count; $field_offset++) { printf ('%'.$field_width[$field_offset].'s | ', filepro_retrieve ($row_offset, $field_offset)); } } echo "\n", $separator; ?> </pre>
PHP Functions Essential Reference. Copyright © 2002 by New Riders Publishing
(Authors: Zak Greant, Graeme Merrall, Torben Wilson, Brett Michlitsch).
This material may be distributed only subject to the terms and conditions set forth
in the Open Publication License, v1.0 or later (the latest version is presently available at
http://www.opencontent.org/openpub/).
The authors of this book have elected not to choose any options under the OPL. This online book was obtained
from http://www.fooassociates.com/phpfer/
and is designed to provide information about the PHP programming language, focusing on PHP version 4.0.4
for the most part. The information is provided on an as-is basis, and no warranty or fitness is implied. All
persons and entities shall have neither liability nor responsibility to any person or entity with respect to
any loss or damage arising from the information contained in this book.
|