so i was just wondering if this is a good practice or not, or for some reason does this type of code affect the speed and functionality of a system ?
$foo = "bar";
$stmt = $db->prepare('SELECT * FROM table WHERE bar=?');
$stmt->bind_param('s',$foo);
$stmt->execute();
$result = $stmt->get_result();
while($row = $result->fetch_assoc()){
$val1 = $row['val1'];
$val2 = $row['val2'];
echo "<section>";
$stmt2 = $db->prepare('SELECT * FROM table2 WHERE bar=?');
$stmt2->bind_param('s',$foo);
$stmt2->execute();
$result2 = $stmt2->get_result();
while($row = $result2->fetch_assoc()){
$val1 = $row['val1'];
$val2 = $row['val2'];
}
$stmt->close();
echo "</section>";
}
$stmt->close();
the first statement could generate 50 or more data, that means that another 50 or more stmt will be produced, is this bad ? thanks for the answers.