AleksandarH

Y2S2 - update_delete.php

May 16th, 2022 (edited)
604
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. include 'config.php';
  3. $query = "UPDATE Chitateli SET address = 'Варна' WHERE id = 1";
  4. $result = mysqli_query($dbConn, $query);
  5. $query = "DELETE FROM Chitateli WHERE id = 2";
  6. $result = mysqli_query($dbConn, $query);
  7. $query = "SELECT * FROM Chitateli";
  8. $result = mysqli_query($dbConn, $query);
  9. $count = mysqli_num_rows($result);
  10. if ($count > 0)
  11. {
  12.     echo "<table border='2'><tr><th>Номер на читателска карта</th><th>Име</th><th>Фамилия</th><th>Адрес</th><th>Телефон</th><th>Година на издаване</th>";
  13.     while ($row = mysqli_fetch_array($result))
  14.     {
  15.         echo "<tr><td>" . $row["id"] . "</td><td>" . $row['firstname'] . "</td><td>" . $row['lastname'] . "</td><td>" . $row['address'] . "</td><td>" . $row['phonenumber'] . "</td><td>" . $row['year'] . "</td></tr>";
  16.     }
  17.     echo "</table>";
  18. }
RAW Paste Data Copied