Jump to content

snoopy1992

New Members
  • Posts

    3
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

snoopy1992's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. 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 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 ?>
  2. It works!! Thank You :D
  3. I am saving to a text file using the fwright command, all the info saves ok but how can I get the data in the text file to have a space in-between each variable <table width="590" border="1"> <tr> <td width="129">Name </td> <td width="335"><?php echo $_POST["name"]; ?></td> </tr> <tr> <td>Account Number</td> <td><?php echo $_POST["accno"]; ?></td> </tr> <tr> <td>Date and Time</td> <td><?php echo $_POST["dt"]; ?></td> </tr> <tr> <td height="45">Lengh of Visit </td> <td><?php echo $_REQUEST["lvisit"]; ?></td> </tr> <td height="45">Reason For call</td> <td><?php echo $_REQUEST["rcall"]; ?></td> </tr> </tr> <td height="45">Cost of Extra Medication</td> <td><?php echo $_REQUEST["com"]; ?></td> </tr> </table> <br /> <?php $name=$_REQUEST['name']; $accno=$_REQUEST['accno']; $dt=$_REQUEST['dt']; $lvisit =$_REQUEST['lvisit']; $rcall =$_REQUEST['rcall']; $com =$_REQUEST['com']; $fp = fopen("data.txt", 'ab'); fwrite($fp,$name); fwrite($fp,$accno); fwrite($fp,$dt); fwrite($fp,$lvisit); fwrite($fp,$rcall); fwrite($fp,$com); fclose($fp); ?>
×
×
  • 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.