I have a php code for inserting records, now this code inserts more than two records at a time.
The code is below. I want the code NOT be inserting a record in case a form variable or value is empty. I have tried but I can not get it. I mean if a user did not key any value in text filed form, then submit, it should not insert the value but skip and go to another row or record that I have value. Iam asking this becuase when I submit with all form values or variables, the php code is inserting without a problem but when I submit a form with some form values or variables Iam get an errory saying ('Error, insert query failed'); .

You will help will be appreciated.


<?php

$fClaimCode = $_POST["Allowance3"];
$fAmountRequired = $_POST["Amount3"];


$gClaimCode = $_POST["Allowance4"];
$gAmountRequired = $_POST["Amount4"];


$hClaimcode = $_POST["Allowance5"];
$hAmountRequired = $_POST["Amount5"];


$iClaimcode = $_POST["Allowance6"];
$iAmountRequired = $_POST["Amount6"];


$jClaimcode = $_POST["Allowance7"];
$jAmountRequired = $_POST["Amount7"];

$lClaimcode = $_POST["Allowance9"];
$lAmountRequired = $_POST["Amount9"];

$zramoney = $_POST["AmountForZRA"];
$employemoney = $_POST["AmountforEmployee"];

$Docem = $_POST["DocumentName"];
$mdetails = $_POST["details"];



$mysql_query="INSERT INTO aftertravel (AllowanceId,ClaimCode,Amount)".
"VALUES ('$tAllowanceID','$dClaimCode','$dAmountRequired')" ;
mysql_query($mysql_query) or die('Error, insert query failed');


$mysql_query="INSERT INTO aftertravel (AllowanceId,ClaimCode,Amount)".
"VALUES ('$tAllowanceID','$eClaimCode','$eAmountRequired')" ;
mysql_query($mysql_query) or die('Error, insert query failed');


$mysql_query="INSERT INTO aftertravel (AllowanceId,ClaimCode, Amount)".
"VALUES ('$tAllowanceID','$fClaimCode','$fAmountRequired')" ;
mysql_query($mysql_query) or die('Error, insert query failed');


$mysql_query="INSERT INTO aftertravel (AllowanceId, ClaimCode,Amount)".
"VALUES ('$tAllowanceID','$gClaimCode','$gAmountRequired')" ;
mysql_query($mysql_query) or die('Error, insert query failed');

$mysql_query="INSERT INTO aftertravel (AllowanceId,ClaimCode,Amount)".
"VALUES ('$tAllowanceID','$hClaimcode','$hAmountRequired')" ;
mysql_query($mysql_query) or die('Error, insert query failed');


$mysql_query="INSERT INTO aftertravel (AllowanceId,ClaimCode,Amount)".
"VALUES ('$tAllowanceID','$iClaimcode','$iAmountRequired')" ;
mysql_query($mysql_query) or die('Error, insert query failed');

$mysql_query="INSERT INTO aftertravel (AllowanceId,ClaimCode,Amount)".
"VALUES ('$tAllowanceID','$jClaimcode','$jAmountRequired')" ;
mysql_query($mysql_query) or die('Error, insert query failed');

$mysql_query="INSERT INTO aftertravel (AllowanceId,ClaimCode,Amount)".
"VALUES ('$tAllowanceID','$lClaimcode','$lAmountRequired')" ;
mysql_query($mysql_query) or die('Error, insert query failed');



$mysql_query="INSERT INTO attdocumentation (AllowanceId,Documentname,Details)".
"VALUES ('$tAllowanceID','$Docem','$mdetails')" ;
mysql_query($mysql_query) or die('Error, insert query failed');

?>