dynamic dropdown in php using array and select name

I am trying to create the dynamic dropdown menu in php , taking result from array

here is the code

unction Display_Screen2()
 global $secret_question_name;

 #echo $secret_question_name[2];
 print <<< HERE
 <table border="0" width="100%" cellspacing="0" cellpadding="1">
User Secret Question

   <select name = "User_Secret_Question" tabindex="2">
     while($i=0 < 4)
     <option value = \"$secret_question_name[$i]" size="20">$secret_question_name[$i] </option>;

I do not think it ever execute the while loop,  My main object is write one  <option value ... >
and put the data from  array and to display the final dripdown menu

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

instead of the while use for

     for ($i = 0; $i < 4; $i++) {
         <option value = \"$secret_question_name[$i]" size="20">$secret_question_name[$i] </option>;


also the while is inside of the print statement so try something like this


function Display_Screen2() {

global $secret_question_name;

print       "<form>" .
      "<table border='0' width='100%' cellspacing='0' cellpadding='1'>" .
      "<tr>" .
      "<td>" .
      "User Secret Question " .
      "<select name = 'User_Secret_Question' tabindex='2'>" ;

      for ($i = 0; $i < 4; $i++) {
            print "<option value='" . $secret_question_name[$i] . "' size='20'>" . $secret_question_name[$i] ."</option>";

print       "</select>" .
      "</td>" .



Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Development Software

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.