I have the following code in my PHP program:

$query = "SELECT * FROM board_members";
$result = mysql_query($query) or die(mysql_error());        
$data = array(); // create a variable to hold the information
while (($row = mysql_fetch_array($result, MYSQL_ASSOC)) !== false){
  $data[] = $row; // add the row in to the results (data) array
}

print_r($data); // print result

This give me the following corrrect data for the table:
Array ( [0] => Array ( [FirstName] => Alona [LastName] => Burnett [Amount] => 1000.00 ) [1] => Array ( [FirstName] => Anna Marie [LastName] => Hartman [Amount] => 1200.00 ) [2] => Array ( [FirstName] => Anne [LastName] => Ferguson [Amount] => 500.00 ) [3] => Array ( [FirstName] => Bobbie [LastName] => McLaughlin [Amount] => 900.00 )

How can I echo for example the third person's FirstName, then LastName, then Amount?
I would like to use something like echo $data[FirstName][2] to get the first name from the 3rd row.

Following way you can refer third record (index=2).

echo "Third person: ".$data[2]['FirstName']." ".$data[2]['LastName']."-".$data[2]['Amount'];

Thanks urtrivedi!

That works - just what I was looking for.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.