drewtheman Posted July 3, 2007 Share Posted July 3, 2007 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? Quote Link to comment Share on other sites More sharing options...
rhyspaterson Posted July 3, 2007 Share Posted July 3, 2007 Please use code brackets to help us understand your script better. Quote Link to comment Share on other sites More sharing options...
corbin Posted July 3, 2007 Share Posted July 3, 2007 To be honest, I have no idea what you're trying to do. Are you trying to read in an entire directory of files and then output certain data from them? Quote Link to comment Share on other sites More sharing options...
drewtheman Posted July 3, 2007 Author Share Posted July 3, 2007 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. Quote Link to comment Share on other sites More sharing options...
corbin Posted July 3, 2007 Share Posted July 3, 2007 Are all the files formatted uniformly? If they are, can you post an example of what a file would look like? Quote Link to comment Share on other sites More sharing options...
drewtheman Posted July 3, 2007 Author Share Posted July 3, 2007 Each file would look something like this: <? $name = "Jeff and Cindy Roberts"; $event = "Wedding"; $date = "06-07-2007"; ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.