Hey all. This is related to a post that halo helped resolve from yesterday. I was having trouble printing an array generated from fetchAll. That problem is now resolved but the point of the fetch was to use the results in a drop down menu. (note: I already have a workaround for this problem but I'm interested in why this particular method does not work)
//assume error reporting and proper DB connection
$loopcounter = 0;
$names = $db->query("SELECT Last_Name,First_Name FROM ShareholderNames WHERE ShareholderID < 10000 AND ShareholderID != 0 ORDER BY Last_Name ASC");
$name = $names->fetchAll();
$totalnumber = (count($name));
print<<<_Test_
<select name="First_Last" size="10">
<optgroup label=Shareholder>
_Test_;
while($loopcounter < $totalnumber)
{
/* THIS IS MY WORKAROUND$x = $name[$loopcounter][0];
$y = $name[$loopcounter][1]; And then put $x and $y in place of $name[$loopcounter][0] and $name[$loopcounter][1]
*/
print<<<_Test2_
<option>$name[$loopcounter][0],$name[$loopcounter][1]</option>
_Test2_;
$loopcounter++;
}
print<<<_Test3_
</optgroup>
_Test3_;
This ends up printing out a scroll down list with all the entries being Array[0],Array[1].
Why is this happening? As always, thanks for your time!