Hello Experts,
I am getting unwanted result.Please help!
Here is the function:
function ArrayResults($result){
while ($row = mysql_fetch_assoc($result)){
//echo $row["first_name"]; //tested :works!!
$this->arr2[] = $row;
}
return $this->arr2;
}
I called the function and used the print_r to see how is the array:
$mysql->ArrayResults($mysql->ExecuteSQL("SELECT * FROM Employee"));
print_r($mysql ->arr2);
Array look weird:
Array ( [0] => Array ( [id] => 1 [first_name] => Jack [last_name] => Schrvaski [start_date] => 1999-07-20 [end_date] => 2011-07-21 [salary] => 1224.56 [city] => Toronto [description] => Programmer ) [1] => Array ( [id] => 2 [first_name] => David [last_name] => Moron [start_date] => 1999-07-20 [end_date] => 2011-07-21 [salary] => 1224.56 [city] => Toronto [description] => Designer ) [2] => Array ( [id] => 3 [first_name] => Eric [last_name] => Ron [start_date] => 1998-08-29 [end_date] => 2011-03-21 [salary] => 1114.56 [city] => Toronto [description] => Tester ) [3] => Array ( [id] => 4 [first_name] => Frost [last_name] => Robert [start_date] => 1999-01-10 [end_date] => 2011-07-10 [salary] => 2114.56 [city] => Toronto [description] => Manager ) [4] => Array ( [id] => 5 [first_name] => Robin [last_name] => Wood [start_date] => 2009-12-22 [end_date] => 2012-02-13 [salary] => 1000.00 [city] => Thronhill [description] => System Analyst ) )
I tried to get a single data using:
print_r($mysql ->arr2[1][2]);
shows no output.But if i type :
print_r($mysql ->arr2[1]['first_name']);
I get David.My question is how to set the array so that I can use loop to get output.
like:
print_r($mysql ->arr2[$i][$j]);
Please help.