Simple task list frontend rewrite

Posted on


I was recently going through some code that I wrote a while ago as an effort to improve my code.

There was one foreach statement that I was especially proud of the rewrite as I believe it is much more readable than it was before, and I believe it will last longer now.

This code in particular is simply a table body that has a check box (Basically a status check) and a plaintext “task” that was assigned to users stored in a database.

Here is the old code:

$taskuid = $tasks['uid'];
$type = "task";
foreach($taskData as $key => $value) {
echo "<tr style='" . (($value['status'] == 1) ? "background-color:green;text-decoration:line-through;" : "") . "'>";
echo "<td onclick='toggleCheck($key, $taskuid, "$type"")' style='vertical-align:middle






. (($value['status'] == 1) ? ""<

Leave a Reply

Your email address will not be published. Required fields are marked *