I am trying to store data in an array, and then output a key of that array whenever I want. I have a table of staff data and am successfully using print_r to print the array, but cannot use "echo $staff_data;" to do anything. I feel like I am very close, but it is slipping by me.
I have two functions:
function staff_data() {
$staff_data = array();
$query = mysql_query("SELECT * FROM `staff`");
while ($row = mysql_fetch_assoc($query)) {
$staff_data[] = $row;
}
}
function output_staff($staff_data) {
return '<ul><li>' . implode('</li><li>', $staff_data) . '</li></ul>';
}
I am not receiving the correct output. Currently I get these errors:
Notice: Undefined variable: staff_data in C:\xampp\htdocs\projects\etk\internal\staff.php >on line 11
Warning: implode(): Invalid arguments passed in C:\xampp\htdocs...line 3
which is pointing to my output_staff function. Can someone point me in the right direction?
output_staff()? It looks like you aren't passing an array to that function.$staff_data;