Jump to content

Extracting info from files in a flat file database


drewtheman

Recommended Posts

Hello all,

 

I am in dire need of a script that can read the variable files from within a file (ie: client_01.inc).

 

I already know about the include()  and require() commands, but I want a table with a script that points to a directory of files.  I have client files each with variables in each file and the table needs to extract the info from each file in that directory to display in the table.  Here is the code I'm using to pull the files from the directory.

 

<?

$default_dir = "../clients";

if(!($dp = opendir($default_dir))) die("Cannot open $default_dir.");

while($file = readdir ($dp))

if($file != '.' && $file != '..' )

 

echo "<center><table BORDER=0 CELLSPACING=2 CELLPADDING=0 COLS=5 WIDTH=\"600\">

<tr BGCOLOR=\"#F7EEEE\"><td WIDTH=\"238\"><font face=\"Arial,Helvetica\"><font size=-1>$name</font></font></td><td WIDTH=\"75\"><font face=\"Arial,Helvetica\"><font size=-1>$date</font></font></td><td WIDTH=\"125\"><font face=\"Arial,Helvetica\"><font size=-1>$event</font></font></td><td WIDTH=\"30\"><font face=\"Arial,Helvetica\"><font size=-1><a href=\"edit_account.php?client=$file\">Edit</a></font></font></td><td WIDTH=\"30\"><font face=\"Arial,Helvetica\"><font size=-1><a href=\"delete_account.php?client=$file\">Delete</a></font></font></td></tr></table></center>";

 

closedir($dp);

?>

 

Can anyone tell me what I'm missing?

Link to comment
Share on other sites

Yes.  Exactly.

 

I'm trying to output the information from each file in the directory to a table.

 

So as an example, I'd like to have a column labeled as 'Date'.  When I run the script that currently gives me the name of each file in the directory, I'd also like it to read the date variable from each of the files and place it in the 'Date' column.

 

I hope this makes more sense. 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.