Quick (and hopefully easy) question . . .
I’m trying to figure out where in the following php code to place the tabindex number. What the code does is show the already selected answer that has been saved to a MySql table. I have other fields before and after and would like to be able to tab through them all.
I’ve tried different places but keep getting this error - Parse error: syntax error, unexpected T_LNUMBER, expecting ',' or ';'
Hope someone can help me out.
Thanks
[PHP]
<?php
// the list in PHP terms (in an array)
$dropDownList = array (
"",
"Yes",
"No",
);
// grab data from database
$result = mysql_query("SELECT `myfield` FROM `MYTABLE` WHERE ID='{$_SESSION['ID']}'");
// put data into an array
$dataArray = mysql_fetch_array($result);
// now output
echo "<select name=\"myfield\">\n";
foreach($dropDownList as $listItem)
{
// output <option> for this item in the list
// if this item matches DB value, then we put in SELECTED.
if ($dataArray[0] == $listItem)
{
echo "<option value=\"{$listItem}\" SELECTED>{$listItem}</option>\n";
}
// otherwise, just output it normally
else
{
echo "<option value=\"{$listItem}\">{$listItem}</option>\n";
}
}
echo "</select>";
?>[/PHP]