hi, i am working on patient data forms for clinic visits. I devised an HTML form which input into a mysql database using php. Some parameters like blood pressure is set as integer variables in the database, set as NULL, meaning they can (and should) be empty if no data is input. I have searched the net and found out how html forms pass POST data as strings which cause problems for numerical type variables, thus ending up as '0' instead of NULL. If i use phpmyadmin, there is no problem since there is a null checkbox for fields that can be NULL, and the data is correctly input as 'empty' not '0'. But i want a friendlier interface than phpmyadmin for medical students and medical staff to use, thus... the need for html form.
So... the question is, can anyone help me to either:
1. come up with HTML/PHP code to place a null checkbox for the html form? OR
2. come up with HTML/PHP code to ignore form fields that are left blank?
this is the "insert" php code:
CODE
<?
$database="stroke";
$table="eclinic";
$NRIC=$_POST['NRIC'];
$TCUDATE=$_POST['TCUDATE'];
$BESTSYS=$_POST['BESTSYS'];
$BESTDIAS=$_POST['BESTDIAS'];
$HR=$_POST['HR'];
$Weight=$_POST['Weight'];
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query ="INSERT INTO `eclinic` SET `NRIC`='$NRIC' , `TCUDATE`='$TCUDATE' , `BESTSYS`='$BESTSYS' , `BESTDIAS`='$BESTDIAS' , `HR`='$HR', `Weight`='$Weight' ";
mysql_query($query);
mysql_close();
?>
This is just a very abbreviated version as there are many other variables (blood glucose, cholesterol levels etc). The variable to focus on is Weight. It is "NULL"-able (accepts NULL). Previous attempts of mine using HTML forms always gives me a zero.
We don't always get the patient's weight (aside from the several variables I have left out), so it would be left blank from time to time... but I do not want zeroes where the data ought to be empty/ NULL.
Thanks in advance!