I have a form in which i use two dimensional array for field names.The fields names are below
myform[message][]
myform[name][]
myform[add][]
it means there are three arrays.Every array has arrays inside it.when i var_dump my form after putting values and submitting it.I get the below structure of 2d array.
array
''message'' =>
array
0 => string 'adnan' (length=5)
1 => string 'khan' (length=4)
2 => string 'salman' (length=6)
''name'' =>
array
0 => string 'khan' (length=4)
1 => string 'kamran' (length=6)
2 => string 'khan' (length=4)
''add'' =>
array
0 => string 'asad' (length=4)
1 => string 'khan' (length=4)
2 => string 'abrar' (length=5)
As you can see the associative array.I want to store the values of message,name and add in a database table having three fields to store the values of message,name and add fields in a single query by using some loop like foreach.
when i use this code
foreach($_REQUEST['myform'] as $val)
foreach($val as $v)
{
echo $v;
}
I get all the values of the array.But i think i am unable to save it to database table
as all the values are in the variable $v.How to store message in a message field,name in name field and add in an add field in a table of a db.
please advice.Thanks
That will give you the field name to work with. I assume you know how to insert entries into a database already.