I need to compare 2 different columns in a table: tbl_Try (country, name). if there are 2 coloumns with the same value do nothing. If there is no the same values of these 2 columns the same insert.
this is the connection to the database:
      <?php
        require_once("menu.php");
        require_once("function.php");
    ?>
Here is the main code (read the comments to try to understand)
            <?php
             $conn = ConnectToSql();
             $query= "Select *  FROM tbl_countries";
             $result = mysqli_query($conn, $query)
             or die("Error in query: ". mysqli_error($conn));
             $choose = '';
            while ($row = mysqli_fetch_assoc($result))
            {
                $choose .= '<option value = "'.$row['name'].'">'.$row['name'].'</option>';
            }
            ?>
        <div class="form-group">
          <label class="control-label col-sm-2" for="Country">Choose a country:</label>
          <div class="col-sm-5">
              <select class="form-control" name ="reg_country" >
                  <option></option>
                  <?php echo $choose;?></select>
          </div>
            </div>
            <br>
            <div class="form-group">
          <div class="col-sm-offset-4 col-sm-10">
            <button type="submit" name="submit" class="btn btn-default">Submit</button>
          </div>
        </div>
            <?php
             if(isset($_POST['submit']))
             {
                $country = $_POST['reg_country'];
                $_SESSION['country'] = $country;
                 $query2 = "SELECT name,id FROM tbl_flowertypes ";
                 $result2 = mysqli_query($conn, $query2) or die("Error in query: ". mysqli_error($conn));
                 $result2_rows = mysqli_num_rows($result2);
              //this code is not working. Need to count the 2 columns (name AND country) 
              // if in tbl_try there is already country:italy name:12 red roses. DO NOTHING if there is no data the same
              // insert data
                 $query3 = "SELECT count(*) FROM tbl_try WHERE name='$_SESSION[flower_type_name]' AND country ='$_SESSION[country]' ";
                 $result3 = mysqli_query($conn, $query3) or die("Error in query: ". mysqli_error($conn));
                 $result3_rows = mysqli_num_rows($result3);
               // loop counting how many record are in table flowertype and loop to insert data in tbl_try (this code is working fine)     
            for($i = 1; $i <= $result2_rows;$i++)
                {
                    while($row = mysqli_fetch_assoc($result2))
                        {
                            $_SESSION['flower_type_name'] = $row['name'];
                        // this is the insertion of the data
                            $inserting = "INSERT INTO tbl_try(name,country) VALUES ('$row[name]','$_SESSION[country]')";
                            $result3 = mysqli_query($conn, $inserting) or die("Error in query: ". mysqli_error($conn));
                        }
                }
             }
the result need to be:
the database need to do in insertion once . ONLY IF THERE IS NO THE SAME COLUMNS IN THE TABLE. IF THERE IS THE SAME DATA JUST DO NOTHING.
I need to complete this code by showing a table with some records but i know how to do that.
Any Suggestions?
 
    