This seems like it would be simple enough but I can't figure it out!
I have a form with 3 fields for the user to fill out. They don't have to fill out all of the fields, and this is where my problem is. If I leave the option #3 empty, then it still gets inserted into the database, but it's just an empty row. I don't want this. I want to only insert into the database the fields that were filled in. How would I do this?
Here's what I have:
$option1 = $_POST['option1'];
$option2 = $_POST['option2'];
$option3 = $_POST['option3'];
And my insert query:
$add_answers = "INSERT INTO answers (answer) VALUES ('$option1'), ('$option2'), ('$option3')";
Thanks in advance.