Jump to content

Text to table


snoopy1992

Recommended Posts

I am making a php program which can read variables from a txt file and puts them in a table.

I have two variables working in the table (Name and Account Number)but the others just appear at the top of the page rather then in the table. What am i doing wrong :shrug:

i also need to make it so it will add the next lot of data underneath the first lot collected

 

<?php

print "<table>";

print "<tr>";

print "<th>Name</th><th>Account Number</td>Time and Date<th>Lengh of Visit<th/>Reason For

 

Call<th>Cost of Extra Medication  ";

$file = fopen('data.txt', 'r'); // Open data.txt for reading from beginning

while(!feof($file)) { // While not end of file

$line = fgets($file); // Read a line from the file

if($line) {

$record = explode(",",$line);

print

 

"<tr><td>$record[0]</td><td>$record[1]</td></td>$record[2]</td>$record[3]</td>$record[4]<

 

/td></</td>$record[5]</td>";

}

}

print "</table>";

fclose($file); // Close the file

 

?>

Link to comment
https://forums.phpfreaks.com/topic/203618-text-to-table/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.