this multidimensional array can be accessed by a index.
<?php
echo '
punarray = new Array(';
$q = mysql_query("SELECT id FROM cats WHERE breed LIKE '%(%'
ORDER BY breed");
$total = mysql_num_rows($q);
$count = 0;
while($i = mysql_fetch_object($q))
{
$breed = $i->id;
$count++;
print("new Array(\n");
$q2 = mysql_query("SELECT bid,name FROM dogs WHERE
kennel ='$kennelid' AND breed = '$breed'");
$total2 = mysql_num_rows($q2);
$count2 = 0;
if ($total2 > 0)
{
while($i2 = mysql_fetch_object($q2))
{
$count2++;
$breederid = $i2->bid;
$breedername = $i2->name;
if ($count2 < $total2)
print("new Array(\"$breedername\", \"$breederid\"),\n");
else
print("new Array(\"$breedername\", \"$breederid\")\n");
}
}
if ($count < $total) print("),\n");else print(")\n");
}
echo ');';
now we can access the array by the following function.
i am here pupulating a dropdown by the values of the
array according to the index.
function fillSelectFromArray(index,dropdown)
{
var array=punarray[index];
var j=0;
for (i = 0; i < itemArray.length; i++) {
dropdown.options[j] = new Option(array[i][0]);
j++;}
}