Advertisement
xShub

PHP loop for mysql

Apr 17th, 2024
597
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.48 KB | None | 0 0
  1. // Query per selezionare i record dalla tabella corso
  2. $sql = $conn->prepare("SELECT id_corso, corso FROM corso WHERE id_gruppo = ? ORDER BY id_corso");
  3. $sql->bind_param("i", $id_gruppo);
  4. $sql->execute();
  5. $result = $sql->get_result();
  6. $conn->close();
  7.  
  8. // Controllo se ci sono risultati
  9. if ($result && $result->num_rows > 0) {
  10.     while ($row = $result->fetch_array()) {
  11.         $json[] = $row;
  12.     }
  13. } else if ($result === false) {
  14.     error_return_json_error(ERR_DATABASE);
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement