Hello:
I have the following group of form elements in a form:
<input type="text" name="subhead[]">
When the form is submitted it simply inserts the subhead array index values into a database as follows:
$num_rows = count($subhead);
for ($i = 0; $i < $num_rows; $i++) {
$sSQL = "INSERT INTO files (file_text, hdr_id) VALUES ('$subhead[$i]', '$id')";
$result=db_query($sSQL);
}
The problem lies when one of the form elements is not defined in the form. This will insert a blank line in the database. How can I work around this so that I can use an array and skip over the indexes in the array that don't have a value?
Thanks,
Troy