Няма описание

script_template_scales.php 1.1KB

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. $servername = "127.0.0.1";
  3. $username = "root";
  4. $password = "";
  5. $database = "trabajoolas5";
  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 `templates`');
  14. while ($row = mysqli_fetch_array($allrubrics)) {
  15. foreach (json_decode($row['contents']) as $criterion) {
  16. $criterion_id = $criterion->id;
  17. $querySelect = "select * from template_criterion where template_id ={$row['id']} and criterion_id = {$criterion_id}";
  18. $makeQuery = mysqli_query($conn, $querySelect);
  19. if (!mysqli_num_rows($makeQuery)) {
  20. $query2 = "insert into `template_criterion` (`template_id`, `criterion_id`) values ({$row['id']}, {$criterion_id});";
  21. $makeQuery = mysqli_query($conn, $query2);
  22. if (!$makeQuery) {
  23. echo "Connection failed: " . mysqli_error($conn) . $query2;
  24. }
  25. }
  26. }
  27. }