Been researching this for an hour. I give up. I'm trying to create an array after populating the array from a MySQL table.
I then want to output the array text elements across the top of a table (table headings)
$sqlRotations="SELECT id, rotationName FROM sched_rotations";
$resultRotations=mysql_query($sqlRotations);
$arrayRotations = array();
while($row_Rotation=mysql_fetch_assoc($resultRotations)){
$arrayRotations[]=$row_Rotation;
}
...then I'm trying to print out the "rotationName" as table column headings:
<table>
<tr>
<?
foreach( $arrayRotations as $key => $value){
echo "<td>Id: $key, Rotation:". $arrayRotations[$value]." </td>";
}
?>
</tr>
Unfortunately, this gives me the following output in < t d > format:
Id: 0, Rotation: Id: 1, Rotation: Id: 2, Rotation: Id: 3, Rotation: Id: 4, Rotation: Id: 5, Rotation: Id: 6, Rotation: Id: 7, Rotation: Id: 8, Rotation: Id: 9, Rotation: Id: 10, Rotation:
Furthermore if I change the for key value echo to this:
foreach( $arrayRotations as $key => $value){
echo "<td>Id: $key, Rotation:". $value." </td>";
}
then I get this output:
Id: 0, Rotation:Array Id: 1, Rotation:Array Id: 2, Rotation:Array Id: 3, Rotation:Array Id: 4, Rotation:Array Id: 5, Rotation:Array Id: 6, Rotation:Array Id: 7, Rotation:Array Id: 8, Rotation:Array Id: 9, Rotation:Array Id: 10, Rotation:Array