暫無描述

script.php 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. $servername = "127.0.0.1";
  3. $username = "root";
  4. $password = "";
  5. $database = "trabajoolasdatos";
  6. // Create connection
  7. $conn = mysqli_connect($servername, $username, $password, $database);
  8. // Check connection
  9. if (!$conn) {
  10. die("Connection failed: " . mysqli_connect_error());
  11. }
  12. echo "Connected successfully\n";
  13. $allrubrics = mysqli_query($conn, 'select id, contents from `rubrics`');
  14. $all_criterion_objectiveOutcome = mysqli_query($conn, 'select * from criterion_objective_outcome');
  15. while ($row = mysqli_fetch_array($all_criterion_objectiveOutcome)) {
  16. $id = $row['id'];
  17. $criterion_id = $row['criterion_id'];
  18. $program_ids = mysqli_query($conn, "select * from program_criterion where criterion_id = {$criterion_id}");
  19. while ($prog_id = mysqli_fetch_array($program_ids)) {
  20. if ($prog_id['program_id'] != null) {
  21. $query = "insert into `program_criterion_objective_outcome` (`program_id`,`cri_obj_out_id`) values ({$prog_id['program_id']},{$id})";
  22. $makeQuery = mysqli_query($conn, $query);
  23. if (!$makeQuery) {
  24. die("Connection failed: " . mysqli_error($conn) . $query);
  25. }
  26. }
  27. }
  28. }