[phplib] Array Insanity From: Rex Byrns (rexb <email protected>)
Date: 09/29/00

I recently posted a question about how to get the equivalent functionality
of mysql_fetch_array. It is working well.

I think that I now have some problem in not understand what scalar and
associative arrays are.

My code is ........

$query="Select * from Locales order by ID ASC";
$db->query($query);
$count = $db->num_rows();
$newarray = array();
$j = 1;
$i = 1;
$db2 = new DB_VIC;

while ($db->next_record()) {

            $ID=$j;
            $OldID=$db->f('ID');
            $Name=$db->f('Name');
            $Parent=$db->f('Parent');
                 $OldParent = $db->f('Parent');

$newarray[$j]=array(ID=>$j,Name=>$Name,Parent=>$Parent,Pname=>'',Used=>'0');
          $j++;
        }

$garray = array();
$garray = array($newarray);
$c = count($newarray);
echo $c." elements in newarray<BR>";
$i = 0;
$j = 0;

while ($i <= $c){
        $parent = $newarray[$i][Parent];
        $na = $newarray[$i][Name];
        #echo $na;
        reset($garray);
        $gcount = count($garray);
        $j = 1;

        While ($j <= $gcount){
                if($garray[$j][ID]=$parent){
                        $newarray[$i][Used]='1';
                        $newarray[$i][Pname]= $garray[$j][Name];
                }
                $j++;
        }

        $i++;
}

The problem is that $newarray[$i][Pname] = the ID instead of the Name, I
tried changing things around and all I can get returned are the field values
of the original array.

Help me please.

---------------------------------------------------------------------
To unsubscribe, e-mail: phplib-unsubscribe <email protected>
For additional commands, e-mail: phplib-help <email protected>