Forum Moderators: coopster
<?php
$fp = fopen('male.txt','r');
if (!$fp) {echo 'ERROR: Unable to open file.</table></body></html>'; exit;}
while (!feof($fp)) {
$line = fgets($fp, 1024); //use 2048 if very long lines
list ($SURNAME, $CHRISTIAN NAME, $TITLE, $SONGS INCLUDE, $PRICE,) = split ('\¦', $line);
echo '
<tr>
<td>'.$SURNAME.'</td>
<td>'.$CHRISTIAN NAME.'</td>
<td>'.$TITLE.'</td>
<td>'.$SONGS INCLUDE.'</td>
<td>'.$PRICE.'</td>
</tr>';
$fp++;
}
fclose($fp);
?>
it calls on a txt database (male.txt)thats seperated with tabs.Its in the same folder as the html file.
perhaps i should insert the script in its own table row?
HELP.....i'm drowning..
The script you posted assumes that the values in the file are seperated by pipe symbols (¦)
you could change this to tab, I believe it is: \t
so in the script: change:
list ($SURNAME, $CHRISTIAN NAME, $TITLE, $SONGS INCLUDE, $PRICE,) = split ('\¦', $line);
to
list ($SURNAME, $CHRISTIAN NAME, $TITLE, $SONGS INCLUDE, $PRICE,) = split ('\t', $line);
Else you can make the file pipe-separated. '
Also, it requires the file to contain 5 values in a line (The five mentioned i te script line posted a few lines above).
J.
Beware:
Your page should be named with the .php extension. This is so the web server knows how to handle the PHP snippet for processing.
If it does not work then you need to modify your setup (httpd.conf) to allow for php to parse .html files.
Since you might not have access to it check with your ISP.
Find:
<apachedir>/conf/httpd.conf ......
AddType application/x-httpd-php .php
from here add any extensions that will be processed by PHP
for example:
AddType application/x-httpd-php .php .html
Remember to restart Apache