Hi,
I am new to MySQL. Have to tables, basically I want to go through column 'owner1' from table 'owner' and get for each value(row) all values of column 2 in table 2 that has this value as the key and put this value in a unique javascript array.
I did this:
It works but is the way I parse data from MySQL appropriate or is there a better more direct way to do this?
Thanks,
Ron
I am new to MySQL. Have to tables, basically I want to go through column 'owner1' from table 'owner' and get for each value(row) all values of column 2 in table 2 that has this value as the key and put this value in a unique javascript array.
I did this:
Code:
$result=MYSQL_QUERY("SELECT * FROM owner ORDER BY `owner1` ASC");
$i = 0;
while ($myrow = mysql_fetch_row($result)) {
$j = 0;
echo "group[$i]=new Array();\n";
$what = "empty";
echo "group[$i][0]=new Option(\"Empty\")\n"; // deal with empty array
$cases=MYSQL_QUERY("SELECT * FROM cases WHERE owner1='$myrow[1]'");
while ($myCases = mysql_fetch_row($cases)) {
echo "group[$i][$j]=new Option(\"$myCases[1]\")\n";
$j++;
}
$i++;
}
It works but is the way I parse data from MySQL appropriate or is there a better more direct way to do this?
Thanks,
Ron