i got this code to display data from a file. It works fine, displays it on a page in normal black text on white background.
<center>To Post ure specs <a href="index.php?file=specs">click here</a></center><?php
$filename = "specs.dat";
$dilm = ":";
if ( file_exists( $filename ) ) {
if ( $fp = fopen( $filename, 'r' ) ){ // open for reading
while ( ! feof( $fp ) ){
$line = fgets( $fp, 1024 );
if ( strlen( $line ) >= 3 ){
$news = explode( $dilm, $line );
echo date( " g.i:s a", $news[0] );
echo "<br />";
echo "$news[1]<br />";
echo "$news[2]<br />";
echo "$news[3]<br />";
echo "$news[4]<br />";
echo "$news[5]<br />";
echo "$news[6]<br />";
echo "$news[7]<br />";
echo "$news[8]<br />";
echo "$news[9]<br />";
echo "$news[10]<br />";
echo "$news[11]<br /><br /><br />";
}
}
fclose( $fp );
}
}
else
{
echo "Error File Does Not Exist! ($filename)";
}
?>
I want it to be dispayed in a table, so i can edit colours etc to go with my site. i tried this but it dont work:
<html><?php
$filename = "specs.dat";
$dilm = ":";
if ( file_exists( $filename ) ) {
if ( $fp = fopen( $filename, 'r' ) ){ // open for reading
while ( ! feof( $fp ) ){
$line = fgets( $fp, 1024 );
if ( strlen( $line ) >= 3 ){
$news = explode( $dilm, $line ); ?>
<center>
<p>To Post ure specs <a href="index.php?file=specs">click here</a></p>
<table width="100%" border="1" cellspacing="0" cellpadding="0">
<tr>
<td width="8%">Date:</td>
<td width="92%"><?php echo date( " g.i:s a", $news[0] ); ?></td>
</tr>
<tr>
<td>Name:</td>
<td><?php echo "$news[1]<br />"; ?></td>
</tr>
<tr>
<td>CPU:</td>
<td><?php echo "$news[2]<br />"; ?></td>
</tr>
<tr>
<td>RAM:</td>
<td><?php echo "$news[3]<br />"; ?></td>
</tr>
<tr>
<td>Motherboard:</td>
<td><?php echo "$news[4]<br />"; ?></td>
</tr>
<tr>
<td>Graphics:</td>
<td><?php echo "$news[5]<br />"; ?></td>
</tr>
<tr>
<td>HDD:</td>
<td><?php echo "$news[6]<br />"; ?></td>
</tr>
<tr>
<td>Disk drive:</td>
<td><?php echo "$news[7]<br />"; ?></td>
</tr>
<tr>
<td>Cooling:</td>
<td><?php echo "$news[8]<br />"; ?></td>
</tr>
<tr>
<td>Case:</td>
<td><?php echo "$news[9]<br />"; ?></td>
</tr>
</table></html>
Any ideas on wot i am doing wrong? might be simple, but i cant tell 🙁