Jump to content

lewishowe

New Members
  • Posts

    3
  • Joined

  • Last visited

lewishowe's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Okay, well there's no error messages... The query just isn't running - When I tick the box, it doesnt update the done field to 1
  2. Had a lot to read, hence the delayed response. Okay, I've had a look at all the suggestions and compiled something from it which I think (thought) would work best.. So the form now looks like (i'll make it prettier at another time): print '<form id="handover" name="handover" method="post" action="newho.php?a=pt1&s=s">'; $toq= mysql_query("SELECT * FROM tasks WHERE done='0'"); while ($row = mysql_fetch_assoc($toq)) { printf('<label for="%d"><span class="labelsystem">%s</span><span class="labelregion">%s</span><span class="labeldescription">%s</span></label>' . PHP_EOL, $row['taskid'], $row['system'], $row['region'], $row['description']); printf('<input id="%d" type="checkbox" name="todo1[]" value="%d" />' . PHP_EOL, $row['taskid'], $row['taskid']); } Now the PHP code.. if (isset($_POST['todo1']) && is_array($_POST['todo1'])) { function isIntString($in) { $bResult = false; $int = (int)$in; if ((string)$int == $in) { $bResult = true; } return $bResult; } $aTodo = array_filter($_POST['todo1'], 'isIntString'); if (!empty($aTodo)) { $sQry = 'UPDATE tasks SET done = 1 WHERE taskid IN (' . implode(', ', $aTodo) . ')'; } } Problem.. it's not working. I'm probably missing something very obvious, but as I'm quite frankly 'inexperienced', I can't see it... Any ideas? Once again thanks for all your help so far. P.S: I like the AJAX idea, but I'd rather not use AJAX for just the one function - Maybe implementing as a whole in the near future would be something to look at - But thanks anyway
  3. Bonjour, Been hunting the internet to find a solution myself, but instead thought I'd just ask on here. After all, if you don't ask, you don't get. Basically, I am creating a internal web based e-mail generator for the company I work for, that will send an e-mail to 'handover' certain 'tasks' to the next team on the next shift - It will be used internal only, so please excuse some of the sloppy coding but we only need it to 'work' - Doesn't really matter how! Anyway, the when someone goes through the form, they are given the options to add 'tasks' to the e-mail, these 'tasks' gets stored into a MySQL database, with the 'DONE' value of '0', ready for when the next person goes to generate the 'handover' - When the next person goes to generate the 'handover', they get a list of the 'tasks', that were previously inserted, by the previous person. Like so: They are given the option to mark the task as done, or not. Now here's the part where I get stuck... The subsequent 'handover' queries the MySQL database to see which 'tasks', have a 'DONE' value of '0' (not done). It then lists them. Here is the code: $toq2= mysql_query("SELECT * FROM tasks WHERE done='0'"); $toq2p = mysql_fetch_array( $toq2 ); $toq2r = mysql_num_rows( $toq2 ); if ($toq2r >= 1) { echo "<table border='0'><tr><td></td><td></td><td></td><td><img src='/assets/tick.png' width='20px' height='20px' border='0' /></td>"; $toq4= mysql_query("SELECT * FROM tasks WHERE done='0'"); while($toq4p = mysql_fetch_array( $toq4 )) { echo "<font color='black' size='2'><tr><td><font size='2'><strong>{$toq4p['system']}</strong></font> - </td><td><font size='2'><em>{$toq4p['region']}</em></font> - </td><td><font size='2'>{$toq4p['description']}</font></td><td><input type='checkbox' name='todo1[]' value='1'></td></font></tr>"; } echo "</table><br />"; } else { echo "<h3><font color='red'>NOTHING TO HANDOVER</font></h3>"; } Problem I have, is that because the amount of tasks is never consistent, I can't have a set query for the amount of values, therefore I need to find a way to dynamically set each row to update the 'done' value in the MySQL table to '1' if the box is ticked and leave it as '0', if the box isn't ticked. I hope I've explained myself well enough and appreciate any help that anyone can provide. Many thanks, P.S: Tasks are created as needed and are NOT in a schedule.. as so: When inserted from here, the value of 'done' is set to '0' - From the task list (picture in original post), if the person ticks the checkbox, I want it to be able to update that value of 'done' to '1'.
×
×
  • 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.