Reading php and associative array from multiple database records

advertisements

I know there have been many questions on associative arrays, but I haven't seen one that explains what I have to do to extract the data from this way of creating one. Assume that I have selected multiple records from the same field in the database.

    while ($Row = mysql_fetch_array($mySQLData))
    {
    $assocarraydata[]= array('field1'=>$Row["field1"]);
    };

I know I can do it this way using the index:

    //Put Data into an regular array
    while ($Row = mysql_fetch_array($mySQLData))
    {
    $field1[] = $Row[field1];
    }

    echo $field1[1];

But I don't know how to do it for the associative array in the first example. Can someone help?


Hard to figure out what you're asking, but if the question is how to produce the same result from the first example, the answer is:

// echo the value of field1 from the second (index 1) row of data
echo $assocarraydata[1]['field1'];