I tried to improve the following function, by using array to fetch the fields to Mysql table. Any workaround to improve the following code ? ( Not to enter so many insert values, as it is already in the array ).
sql_query("INSERT INTO $table VALUES ('', '$array_records[Phone]', '$array_records[Name]', '$array_records[Date_join]', '$array_records[Date_birth]'
I have tried to play around with serialize() function, but I can't make it work.
The table field has similar array element:
'' -- field 1 ( id auto-increment )
$array_records[Phone] -- field 2 ( Branch )
$array_records[Name] -- field 3 Name)
$array_records[Date_join] -- field 4 ( Date_join)
$array_records[Date_birth] -- filed 5 (Date_birth)
Original code:
function add_record(
) {
global $dbi, $table;
$array_records = $_POST['array_records'];
sql_query("INSERT INTO $table VALUES ('', '$array_records[Phone]', '$array_records[Name]', '$array_records[Date_join]', '$array_records[Date_birth]'
)", $dbi);
}