I have the following peace of code. I cant solve how to fetch all the records in the database. I have to use prepare but if I use place holders for $sql then it doesnt work I tried foreach and while but I dont know how to use it. Can someone please tell what code to use to fetch multiple records from a table?
<?php
// make connection to database
$sql = "SELECT id_nr, name FROM table;";
$id_nr =1;
if ($stmt = $conn->prepare($sql)) {
$stmt->bind_param('i', $id_nr);
$stmt->execute();
$stmt->store_result();
$num_of_rows = $stmt->num_rows;
$stmt->bind_result($id_nr, $name);
while ($stmt->fetch()) {
echo ' id number : ' . $id_nr . '<br>';
echo ' name : ' . $name . '<br>';
}
$stmt->free_result();
}
$stmt->close();
mysqli_close($conn);
}
?>

Hello,
I have created this code:
if (w > maxWidth || h > textHeight) {
if (y < x) {
[y, y]
} else {
[x, x]
}
} else {
[value[0], value[1]]
}
It is a piece, but it gives to understand what I want to optimize without the rest.
How to modify this code to work with: Switch Statement instead If/Else mode?
This is a expression of After Effects.
Thanks.

I have this issue with a function where I want to execute 4 different actions inside an if statement. My code looks like this:
function deltagare(){var myTextField1 = document.getElementById('namn');var myTextField2 = document.getElementById('epost'); if(myTextField1.value != "" && myTextField2.value != "")document.getElementById("deltagare-list").value+=myTextField1.value+" "+"("+myTextField2.value+")"+"\n",document.getElementById("deltagare-emaillist").value+=myTextField2.value+",",document.getElementById('namn').value="",document.getElementById('epost').value=""; elsealert("Skriv in både namn och epost!"); }
In this way only the first action gets executed. How can I add the other ones properly?