|
-
May 26th, 2009, 06:31 PM
#1
Thread Starter
Frenzied Member
Filter Table
Here is my php code:
PHP Code:
<?php
echo '<h2>Existing Files on your account:</h2>';
// Define the full path to the folder whose contents you want to list
$path = "uploads/";
// Open the directory
$dir_handle = @opendir($path) or die("Error opening $path");
// Loop through the files
echo '<div style="border: 2px solid rgb(0, 0, 0);">';
echo '<table border=1>';
while ($file = readdir($dir_handle)) {
if($file == "." || $file == ".." || $file == "index.php" ) { continue; }
if (substr($file,($file - 3)) != "raf") {
//List all mp3 files
echo '<tr>';
echo '<td>';
echo $file;
echo '</td>';
$raffile = fopen(("uploads/" . (substr($file,0,($file - 3)) . "raf")), "r") or exit("Unable to
open file!");
//Output a line of the file until the end is reached
while(!feof($raffile))
{
$cline = fgets($raffile);
echo '<td>';
echo (substr($cline,(strpos($cline,"=") + 1)));
echo '</td>';
}
fclose($raffile);
echo '</tr>';
//List all mp3 files
}
}
echo '</table>';
echo '</div>';
echo '<br />';
echo '<BUTTON onclick="window.close();">Close Window</BUTTON>';
// Close
closedir($dir_handle);
?>
There is a folder called uploads, in this folder there are different mp3 files. For each mp3 file there is an raf file with the same name. My code creates a table starting with the name of the mp3 file and then lists every line in the assosciating raf file in a new column.
In most of the lines of the file a = sign can be found. I wrote some code to display only the text following the = sign.
There are multiple lines in each raf file that that do not have = signs instead they start with [.
Here is an example of an RAF file:
Code:
[raf]
audioupdate=03/03/00-12:45:40
audiotype=1
[ann]
user=false
confirmplay=
manualplay=true
[alc]
level=-3dB
[autoplay]
mins=0
sequence=true
[scheduling]
commence=
expire=
timestart=00:00:00
timeend=24:00:00
daysofweek=127
I do not want to list the [raf]/[ann]/[alc]/[autoplay]/[scheduling]. At the moment the table is listing all these lines but instead of, for example, [raf] it is being listed as raf]. Without the opening [.
How do i filter out these lines starting with [?
-
May 26th, 2009, 11:26 PM
#2
Re: Filter Table
this is an ini file. use parse_ini_file().
-
May 27th, 2009, 04:04 PM
#3
Thread Starter
Frenzied Member
Re: Filter Table
Where would i place this function?
-
May 27th, 2009, 04:47 PM
#4
Re: Filter Table
did you go to the link I gave you? parse_ini_file() parses the entire file and puts all of the information into an array. that means you would get rid of all of your fopen() and fread() calls and just loop through the array created to display the information. you can either parse the file with or without sections, and both are shown in examples.
-
May 27th, 2009, 07:03 PM
#5
Thread Starter
Frenzied Member
Re: Filter Table
Thank you, also my file is a .raf file. Would it still be read as a .ini using this function?
-
May 27th, 2009, 07:12 PM
#6
-
May 28th, 2009, 01:47 AM
#7
Re: Filter Table
 Originally Posted by noahssite
Here is my php code:
PHP Code:
<?php
echo '<h2>Existing Files on your account:</h2>';
// Define the full path to the folder whose contents you want to list
$path = "uploads/";
// Open the directory
$dir_handle = @opendir($path) or die("Error opening $path");
// Loop through the files
echo '<div style="border: 2px solid rgb(0, 0, 0);">';
echo '<table border=1>';
while ($file = readdir($dir_handle)) {
if($file == "." || $file == ".." || $file == "index.php" ) { continue; }
if (substr($file,($file - 3)) != "raf") {
//List all mp3 files
echo '<tr>';
echo '<td>';
echo $file;
echo '</td>';
$raffile = fopen(("uploads/" . (substr($file,0,($file - 3)) . "raf")), "r") or exit("Unable to
open file!");
//Output a line of the file until the end is reached
while(!feof($raffile))
{
$cline = fgets($raffile);
echo '<td>';
echo (substr($cline,(strpos($cline,"=") + 1)));
echo '</td>';
}
fclose($raffile);
echo '</tr>';
//List all mp3 files
}
}
echo '</table>';
echo '</div>';
echo '<br />';
echo '<BUTTON onclick="window.close();">Close Window</BUTTON>';
// Close
closedir($dir_handle);
?>
There is a folder called uploads, in this folder there are different mp3 files. For each mp3 file there is an raf file with the same name. My code creates a table starting with the name of the mp3 file and then lists every line in the assosciating raf file in a new column.
In most of the lines of the file a = sign can be found. I wrote some code to display only the text following the = sign.
There are multiple lines in each raf file that that do not have = signs instead they start with [.
Here is an example of an RAF file:
Code:
[raf]
audioupdate=03/03/00-12:45:40
audiotype=1
[ann]
user=false
confirmplay=
manualplay=true
[alc]
level=-3dB
[autoplay]
mins=0
sequence=true
[scheduling]
commence=
expire=
timestart=00:00:00
timeend=24:00:00
daysofweek=127
I do not want to list the [raf]/[ann]/[alc]/[autoplay]/[scheduling]. At the moment the table is listing all these lines but instead of, for example, [raf] it is being listed as raf]. Without the opening [.
How do i filter out these lines starting with [?
You shouldn't be using echo to produce HTML too.
-
May 28th, 2009, 03:35 PM
#8
Thread Starter
Frenzied Member
Re: Filter Table
 Originally Posted by visualAd
You shouldn't be using echo to produce HTML too.
Why? What should i use instead a regular html page with php tags?
-
May 28th, 2009, 06:40 PM
#9
Re: Filter Table
he means that instead of this:
PHP Code:
echo "<table><tr><td width=\"200\">$variable</td></tr></table>";
you should do this:
PHP Code:
<table><tr><td width="200"><?php echo $variable; ?></td></tr><table>
PHP is an embedded language, and should be treated as such. it's not exactly a means to output HTML.
-
May 29th, 2009, 07:17 PM
#10
Thread Starter
Frenzied Member
Re: Filter Table
But what if i wanted the php code to recieve values from a form, $_POST? How can i set the action to a .html?
-
May 30th, 2009, 02:23 AM
#11
Re: Filter Table
you can't post a form to an HTML file. that wouldn't do anything. HTML files are static and cannot be executed.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|