I am trying to add a poll function to a forum. the adding forum has radio buttons which asks the user whether he wants to add a poll or not. If he chooses yes the questions and the answers will be added to the database. I have included five inputs for answers of the poll. since the user sometimes does not put answers in all of them (the poll he inserts has three options for example) so I included empty function as seen below in the code. However I am receiving an error that maximum execution time of of 30 seconds exceeded.

When I remove the empty function I do not receive this error, however all of the five answers will be inserted even if they did not contain any text.

Can someone help?
here is the script

if ($apt->post[pollcheck] == 1)
$question = $apt->format_data($apt->post[pollq]);
$apt->query("INSERT INTO threadquestion (question,thread,userid) VALUES ('$question','$id','$userid')");

         $qid = $apt->insertid();
         $i = 1;
         while ($i <= 5)
             $answer = $apt->format_data($polla[$i]);
			 if (!empty($answer)) {
             $apt->query("INSERT INTO threadanswers (quesid, text, results) VALUES ('$qid','$answer', '0')");
             $i = $i + 1;
This question has already been answered. Start a new discussion instead.