I have a php file and a sample form which is quite big ( around 60 fields and all optional ) Now What i want to do is get whatever parameters were passed and insert them to the table. I created a sample for 15 fields, but i can't go on and keep doing this for 60 items.
$a1 = $_REQUEST['a1'];
$a2= $_REQUEST['a2'];
$a3= $_REQUEST['a3'];
$a4= $_REQUEST['a4'];
$a5= $_REQUEST['a5'];
$a6= $_REQUEST['a6'];
$a7= $_REQUEST['a7'];
$a8= $_REQUEST['a8'];
$a9= $_REQUEST['a9'];
$a10= $_REQUEST['a10'];
$a11 = $_REQUEST['a11'];
$a12 = $_REQUEST['a12'];
$a13 = $_REQUEST['a13'];
$a14 = $_REQUEST['a14'];
$id = $_REQUEST['id'];
include 'conn.php';
$sql = "insert into med_history (a1 ,a2 ,a3 ,a4 ,a5 ,a6 ,a7 ,a8 ,a9 ,a10 ,a11 ,a12 ,a13,a14,id) values(
'$a1','$a2','$a3','$a4','$a5','$a6','$a7','$a8','$a9','$a10','$a11','$a12','$a13','$a14','$id')";
@mysql_query($sql);
echo "Inserted successfully";
Also with this one the problem is error is recieved if some parameter is not passed. So, how to fix it.
I am not using PDO or mysqli because this is done on testing server and not on actual server. When i migrate to the production server i will make the PDO connection