I created a form using javascript and php. I have used a textbox like
<input type="textbox" name="listid" value="" />
I will get an array like 4,6,12,9 etc from $_POST[‘listid’]; I can insert this values into database using serialize and retreive it by unserialize. But what I need to do is, insert 1 for listid=4, 2 for listid=6, 3 for listid=12 and 4 for listid=9. I have used
$count=0;
foreach($_POST['listid]' as $id)
{
$count++;
$db->update('lists',array('order'=>$count),'id ='.$db->quote($id));
}
But it is not working. Only updating first value(listid=4)
What I need to do? Anyone please help??
Thanks!
You will not receive an array from $_POST[‘listid], you will get a string. First split that string into an array, then implement the logic.