New to php, trying to learn about arrays.
What is wrong with the code below? I need to echo out the results in order to pass them to another page.
<?php $stmt = $conn -> prepare(" SELECT MONTHNAME(TimeStamp), COUNT(*) FROM transactions WHERE TimeStamp BETWEEN '2014-01-01' AND '2014-12-31' GROUP BY EXTRACT(MONTH FROM TIMESTAMP);"); $stmt -> execute(); $stmt -> bind_result($month, $days); while ($stmt -> fetch()) { $data[] = array( 'month' => $month, 'day' => $day); } print_r($data); $data = array(); foreach($data as $row) { echo $row['month']; echo $row['day']; } $stmt->close(); ?> When I print_r($data) I can see the array fine in the following format.
Array ( [0] => Array ( [month] => January [day] => 323537 ) [1] => Array ( [month] => February [day] => 217304 ) [2] => Array (...
$data = array();?!header("Location:your_path_to_the_second_page/.$your_variables");