I tried Generating the Selection Option HTML Elements in PHP. First off, I couldn't make the code work with a loop and secondly even after using the most rudimentary way of coding I couldn't make it work properly. So far, the first and third section of the code works fine. But The second section doesn't seem to work. I wonder what is wrong with my code. I am using Localhost with XAMPP V3.2.1
I would love to see if one can implement the dropdown using a loop instead.
<?php
echo "<select style='width: 300px'>";
$securityset1 = array(
'What was your childhood nickname?', 'What is the name of your favorite childhood friend?', 'What street did you live on in third grade?'
);
$i=0;
echo "<option value='";
echo $i++;
echo"'>";
echo $securityset1[0];
echo "</option>";
echo "<option value='";
echo $i++;
echo"'>";
echo $securityset1[1];
echo "</option>";
echo "<option value='";
echo $i++;
echo"'>";
echo $securityset1[2];
echo "</option>";
echo "<br>";
?>
<?php
echo "<select style='width: 300px'>";
$securityset2 = array(
'In what city or town was your first job?', 'Where were you when you first heard about 9/11?', 'What is your dream vacation spot?', 'What is your best friends last name?'
);
$j=0;
echo "<option value='";
echo $j++;
echo"'>";
echo $securityset2[0];
echo "</option>";
echo "<option value='";
echo $j++;
echo"'>";
echo $securityset2[1];
echo "</option>";
echo "<option value='";
echo $j++;
echo"'>";
echo $securityset2[2];
echo "</option>";
?>
<?php
echo "<select style='width: 300px'>";
$securityset3 = array(
'In what city or town was your first job?', 'Where were you when you first heard about 9/11?', 'What is your dream vacation spot?', 'What is your best friends last name?'
);
$j=0;
echo "<option value='";
echo $j++;
echo"'>";
echo $securityset3[0];
echo "</option>";
echo "<option value='";
echo $j++;
echo"'>";
echo $securityset3[1];
echo "</option>";
echo "<option value='";
echo $j++;
echo"'>";
echo $securityset3[2];
echo "</option>";
echo "<option value='";
echo $j++;
echo"'>";
echo $securityset3[4];
echo "</option>";
echo "<br>";
?>
Screenshot of OUTPUT in following link. http://oi57.tinypic.com/20gelfo.jpg
selectelement.