So im having a problem (obviously). I have the following MySQL table data
7 USER1 1,1,1,10,1 The Guys Team 8,7,13,14,16
8 USER1 1,1,1,10,1 The Girls Team 7,12,15
10 USER1 1,1,1,10,1 Dog Team 8,7,14,15
I wrote a function to retrieve the data, and return it.
function ShowSetTeams($coach){
$result = mysql_query("SELECT * FROM `teams` WHERE coach = '$coach'") or trigger_error(mysql_error());
while($row = mysql_fetch_array($result)){
foreach($row AS $key => $value) { $row[$key] = stripslashes($value); }
$id = $row['id'];
$teamname = $row['teamname'];
$team = $row['team'];
$event = $row['event'];
$push .= array($id, $teamname, $team, $event);
}
return $push;
}
When i call the function, as below
$info = ShowSetTeams("USER1");
I get this
ArrayArrayArray
I tried echoing $info[0], $info[1], and $info[2], but get this
Arr
So each line in the info array, is the result array. I should be able to do $info[0][0] and get the first ID value, from the first result right?
Fatal error: Cannot use string offset as an array
Im at a loss. How can i get to each of the values of the returned arrays? And more to the point, how could i run a foreach operation on them such as
foreach( $info as $key => $value){
$key[0] //ID
$key[1] //TEAMNAME
$key[2] //TEAM
$key[3] //EVENT
}