multiple inserts from a form

Greetings…

what is supposed to happen…

each task has an id (task_id) anything that is checked i want to update the status in the db from a 0 to a 1. So the question is this… since every item is task_id how do I update multiple tasks to status 1?

[code]

<?php $db = mysql_connect("$server", "$user", "$password"); mysql_select_db('mentor', $db) or die ('Cannot connect to $db_Database : ' . mysql_error()); $id = $_GET['id']; $result = mysql_query ("SELECT tse.tse_id, tse.tse_name, tasks.tasks_id, tasks.tasks_task, tasks.tasks_week, tasks.tasks_day, tasks.tasks_order FROM tse, tasks WHERE tse.tse_id = $id ORDER BY tasks.tasks_week, tasks.tasks_day, tasks.tasks_order") or die(mysql_error()); while($row = mysql_fetch_array($result)) { $tasksans_id = $row['tasksans_id']; $tasks_tsedone = $row['tasks_tsedone']; $tasks_date = $row['tasks_date']; $tasks_mdone = $row['tasks_mdone']; $tasks_id = $row['tasks_id']; $tasks_task = $row['tasks_task']; $tasks_week = $row['tasks_week']; $tasks_day = $row['tasks_day']; $tasks_order = $row['tasks_order']; $tasks_add1 = $row['tasks_add1']; $tasks_add2 = $row['tasks_add2']; $tasks_add3 = $row['tasks_add3']; $tasks_add4 = $row['tasks_add4']; $tse_id = $row['tse_id']; $tse_name = $row['tse_name']; $tse_weekorder = $row['tse_weekorder']; $weeks_id = $row['weeks_id']; $weeks_1 = $row['weeks_1']; $weeks_2 = $row['weeks_2']; $weeks_3 = $row['weeks_3']; $weeks_4 = $row['weeks_4']; if($count==0){ print'

TSE '.$tse_name.''; $count=1; } if ($tasks_week != $previous_tasks_week){ print '

Week ' . $tasks_week . '


'; $previous_tasks_week = $tasks_week ; } if ($tasks_day != $previous_tasks_day){ print '
Day ' . $tasks_day . '

'; $previous_tasks_day = $tasks_day ; } if ($tasks_id != $previous_tasks_id){ print '
' . $tasks_id . '&nbsp- ' . $tasks_task . '  complete
'; $previous_tasks_id = $tasks_id ; } } ?>[/code]

Posts: 40

View Profile WWW Email Personal Message (Online)

Re: multiple entries from a form
« Reply #8 on: Today at 04:49:30 PM »
Reply with quoteQuote
there is a row called task_complete or something of that nature… it defaults to 0 (not done) when they user puts a check in the box next to the tasks then it will update the row with a 1.

I dont know how to pass all the variables like that - if they check # 1, 6, 47 how do I pass task_id=1, task_id=6 and task_id=47 from the form to the processing page? I think I am to the point where I confused myself as to what is going on

Any help would be apprecaited.

I think this is what your asking…

To pass an array from a form, the checkbox name should be like a php array. Following is an example. Note the brackets in the name tag. That will give you the array you need when processing the form.

<form method="post">
<?php foreach($task_id_array as $id) : ?>
    <input type="checkbox" name="task_ids[]" value="<?=$id?>">Task Id <?=$id?><br />
<?php endforeach; ?>
</form>

Then when you are processing the form you’ll have an array to work with…

$task_ids = $_POST['task_ids'];
foreach($tasks_ids as $tid){
    // process the task id $tid
}
Sponsor our Newsletter | Privacy Policy | Terms of Service