I'm trying to add a table row generated in PHP to a HTML file. Actually I've done this with a simple HTML form and some PHP code, but I would like the new row to be added at the top of the table, not at the bottom... (It's going to be a to-do list for my homework, but without checkboxes.)
Here's the PHP code:
<?php
$file = fopen("index.php","a+") or exit("Unable to open file!");
$since = $_POST["since"];
$since2 = "<tr><td class=\"since\">$since</td>";
$due = $_POST["due"];
$due2 = "<td class=\"due\">$due</td></tr>
";
$user = $_POST["user"];
$user2 = "<td class=\"content\">$user</td>";
if ($_POST["since"] <> "");
{
fwrite ($file,"$since2$user2$due2");
}
fclose($file);
?>
Can anyone help me? (Yeah I know the code isn't clean because it's my first attempt to write PHP.)
Here's an example of a tr
made with the code:
<tr><td class="since">Thu 22th Nov</td><td class="content">example</td><td class="due">Tue 27th Nov</td></tr>
My main point is to have a new tr
added on the top!
Really appreciate any help! (I've looked around and hope this question hasn't been asked yet.)