Forum Moderators: coopster
<script language = "javascript" type="text/javascript">
var structure = new Array();
<?
$i = 0;
while ($row = mssql_fetch_assoc($resultStruc )) {
?>
structure[<?echo $i;?>][0] = <?echo $row['DivisionID'];?>;
structure[<?echo $i;?>][1] = <?echo $row['Symonds Div Level'];?>;
structure[<?echo $i;?>][2] = <?echo $row['Symonds Bus Unit Level'];?>;
structure[<?echo $i;?>][3] = <?echo $row['Symonds Regional Level'];?>;
structure[<?echo $i;?>][4] = <?echo $row['Cost Centre'];?>;
<?
$i++;
}?>
</script>
<?php
echo "<script language = \"javascript\" type=\"text/javascript\">\r\n";
echo "var structure = new Array();\r\n";$i = 0;
while ($row = mssql_fetch_assoc($resultStruc )) {
echo "structure[$i][0] = '".$row['DivisionID']."';\r\n";
echo "structure[$i][1] = '".$row['Symonds Div Level']."';\r\n";
echo "structure[$i][2] = '".$row['Symonds Bus Unit Level']."';\r\n";
echo "structure[$i][3] = '".$row['Symonds Regional Level']."';\r\n";
echo "structure[$i][4] = '".$row['Cost Centre']."';\r\n";
$i++;
}
echo "</script>\r\n";
?>
Actually, I think it may because you didn't specify Array() for the nested array.
<script language = "javascript" type="text/javascript">
var structure = new Array();
<?
$i = 0;
while ($row = mssql_fetch_assoc($resultStruc )) {
?>
structure[<?=$i?>] = new Array(
<?=$row['DivisionID']=?>,
<?=$row['Symonds Div Level']?>,
<?=$row['Symonds Bus Unit Level']?>,
<?=$row['Symonds Regional Level']?>,
<?=$row['Cost Centre']?>
);
<?
$i++;
}
?>
</script>