simple question, I think.
I have the following pdo statements:
$sth = $db->prepare("SELECT person,job FROM orgstructure where department=:dept order by id asc");
$sth->bindParam(':dept', $departmentname, PDO::PARAM_STR);
$sth->execute();
$dataArray = $sth->fetchAll();
echo $dataArray[0]['person'];
echo $dataArray[1]['job'];
the two echos are to test, which work 100%.
Later on in my form, I have a for loop in whcih I provide select box options, based on the outputs of the pdo, as below:
<table>
<?
for ( $i = 1; $i <=50; $i++ ) {
?>
<tr>
<td> Job <? echo $i; ?></td>
<td>
<SELECT NAME=job<? echo $i; ?> id=job<? echo $i; ?> style="width:150px;border: 1px solid #2608c3;color:red">
<? echo "<option selected>".$dataArray[$i]['job']."</option>"; ?>
<option>
<?=$optionjobs?>
</option>
</SELECT>
</td>
<td> Person </td>
<td>
<? echo $i."person: ".$dataArray[$i]['person']."job: ".$dataArray[$i]['job']; ?>
<SELECT NAME=person<? echo $i; ?> id=person<? echo $i; ?> style="width:150px;border: 1px solid #2608c3;color:red">
<? echo "<option selected>".$dataArray[$i]['person']."</option>"; ?>
<option>
<?=$optionpersons?>
</option>
</SELECT>
</td>
</tr>
<?
}
?>
</table>
This however does not work. the select statement is correct and works if I replast the $dataarray with text.
I am assuming the issue is with the $i counter being used inside the $dataArray? any suggestions?
Thanks as always,
<? echo "<option selected>".$dataArray[$i]['person']."</option>";doesnt output anything, it is blank. same goes for jobs field. Thanks again,