I am having issues with a $json variable in my code. For some reason, my php query isn't being encoded into my $json variable.
$sql = "SELECT `$column`, `Year`, `Month` FROM unemployed WHERE year BETWEEN ? AND ? and month= ?";
$stmt = $conn->stmt_init();
$stmt->prepare($sql);
$stmt->bind_param('sss', $gYear, $gYear2, $gMonth);
$stmt->bind_result($Column, $year, $month);
$stmt->execute();
$stmt->store_result();
$numRows = $stmt->num_rows;
$json = array();
if ($numRows) { ?>
<table>
<tr>
<th scope="col"> Hi </th>
<th scope="col"> Year </th>
<th scope="col"> Month </th>
</tr>
<?php while ($row = $stmt->fetch()) { ?>
<tr>
<td> <?php echo $Column; ?> </td>
<td> <?php echo $year; ?> </td>
<td> <?php echo $month; ?> </td>
</tr>
$json['unemployed'][]= $row;
<?php } ?>
</table>
<?php
echo json_encode($json);
var_dump($json);
?>
After running this script, there still isn't anything in my $json variable. Does anyone know why that is? Shouldn't the variable now be an array with my query values (each row would now be part of an array)?