Ill just explain by showing my code:
if($_POST)
{
for ($records = 1; $records <= $_POST['numberofrecords']; $records++)
{
if((!in_array($_POST['user'][$records], $assigned_users, true))||($_POST['user'][$records]==''))
{
$phonePost['user'] = $_POST['user'][$records];
$phonePost['id'] = $_POST['id'][$records];
$this->autoprov_model->update_phone_user($phonePost);
}
else
{
//other actions.....
}
etc....
$assigned_users is a query listing all IDs currently selected.
the relevant html is
<select name=user[<?=$lines;?>] style="position: relative; right: 120px;" onchange="submitform(this)">
<?php if($phone['user_id']=='')echo '<option value="">Unassigned</option>'?>
<?php foreach ($users_list as $user):?>
<?php if($user['id']==$phone['user'])$selected = 'selected="selected"'; else $selected = '';?>
<option value="<?=$user['id'];?>" <?=$selected?>><?=$user['name'];?></option>
<?php endforeach;?>
</select>
Whats happening is that I am posting all kinds of IDs (relevant to the $assigned_user array) but not actually in the array. and also when I post '' (blank) they never get updated and only reach the second section.
I ask here incase I am missing a trick with posting the values as arrays?
user
input element? – Raheel Hasan Apr 23 '13 at 14:52$assigned_users
? – Raheel Hasan Apr 23 '13 at 14:53var_dump($_POST['user'])
– Thomas Clayson Apr 23 '13 at 14:53$records = 1
? – Raheel Hasan Apr 23 '13 at 14:540
as that is how an Array is. – Raheel Hasan Apr 23 '13 at 14:58