I am confused if I can do like this:
$param = "%{$id}%";
$stmt = $conn->prepare("SELECT name, comp, date FROM stats WHERE date = ? AND name LIKE ? ORDER BY date DESC LIMIT 20");
$stmt->bind_param("ss", $param, $_POST['date']);
$stmt->execute();
$result = $stmt->get_result();
$count_rows = $result->num_rows;
$stmt->close(); // CAN I CLOSE IT HERE
while($row = $result->fetch_assoc()){
echo '
<tr>
<td>'.$row['name'].'
<td>'.$row['comp'].'
<td>'.$row['date'].'
</tr>';
}
Question is can i close $stmt->close();
where i do it now or should i close it after while loop?
I tested and it does work but is it wrong?