outcome_id; $querySelect = "select * from rubric_outcome where rubric_id ={$row['id']} and outcome_id = {$outcome_id}"; $makeQuery = mysqli_query($conn, $querySelect); if (!mysqli_num_rows($makeQuery)) { $query2 = "insert into `rubric_outcome` (`rubric_id`, `outcome_id`) values ({$row['id']}, {$outcome_id});"; $makeQuery = mysqli_query($conn, $query2); if (!$makeQuery) { die("Connection failed: " . mysqli_error($conn) . $query2); } } $criteria_id = $criterion->id; $querySelect = "select * from rubric_criterion where rubric_id ={$row['id']} and criterion_id = {$criteria_id}"; $makeQuery = mysqli_query($conn, $querySelect); if (!mysqli_num_rows($makeQuery)) { $query2 = "insert into `rubric_criterion` (`rubric_id`, `criterion_id`) values ({$row['id']}, {$criteria_id});"; $makeQuery = mysqli_query($conn, $query2); if (!$makeQuery) { echo "Connection failed: " . mysqli_error($conn) . $query2; } } } }