I am getting data from a mysql DB using PHP and then displaying it inside a DIV on a web page. the data Im fetching is a list of task and I want the users to be able to delete a task once completed.
Image here:
http://www.picpaste.com/Tasks-esmvwRPX.jpg
(apparently I need 10 reputation points before I can embed a picture in my post!)
This is my PHP code used to display the date:
<section class="tasks">
<div id="all-tasks">
<fieldset class="tasks-list">
<?php
$strSQL = "SELECT Tasks.bolComplete, Tasks.strTask, Tasks.datDueDate FROM Tasks WHERE Tasks.idPeople ='" . $_SESSION['UserID'] . "' AND Tasks.bolComplete ='0' ORDER BY Tasks.datDueDate";
$rs = mysql_query($strSQL);
while($row = mysql_fetch_array($rs)) {
echo '<label class="tasks-list-item left">';
if ($row['bolComplete'] == 1) {
echo '<input type="checkbox" name="task_1" value="' . $row['bolComplete'] . '" class="tasks-list-cb" checked>';
}
else {
echo '<input type="checkbox" name="task_1" value="' . $row['bolComplete'] . '" class="tasks-list-cb" unchecked>';
}
echo '<span class="tasks-list-mark"></span>';
echo '<span class="tasks-list-desc">' . $row['strTask'] . '</span>';
// Convert Date format
$originalDate = $row['datDueDate'];
$newDate = date("d-m-y", strtotime($originalDate));
echo '<span class="tasks-list-date">' . $newDate . '</span>';
echo '</label>';
$i++;
}
?>
</fieldset>
</div>
</section>
How can I capture the index of the row displayed so I can do my delete query against the task that is selected?
I have a primary key on idTask (not displayed in the task list) which I need to capture for my delete statement.
Any help is greatly appreciated.
Thanks in advance. M.