每当我插入数据时,它都会创建两行。一个是空白,另一个是正确的信息。我该如何解决

时间:2019-04-10 17:46:17

标签: php database

我正在将数据插入数据库,但是当我将其插入时,会创建一个空行并显示正确的行以及如何阻止此信息?我正在使用Google图表显示数据

function drawChart() {
         var data = google.visualization.arrayToDataTable([
           ['Name', 'Age'],
           <?php
           while($row = mysqli_fetch_array($result))
           {
                echo "['".$row["Name"]."', ".$row["Age"]."],";
           }
           ?>
         ]);

         var options = {
           chart: {
             title: 'Age Chart',
             subtitle: 'Age Comparison of Site Visiters',
           },
           bars: 'horizontal' // Required for Material Bar Charts.
         };

         var chart = new 
google.charts.Bar(document.getElementById('barchart_material'));

         chart.draw(data, google.charts.Bar.convertOptions(options));
       }
     </script>

  </head>
  <body>
      <form  method="get">
        First Name:<input type="text" name="Name" >
        Age:<input type="text" name="Age" >
        <button type="submit" name="button">Submit</button>

      </form>
      <?php
          $Name = $_GET['Name'];
          $Age = $_GET['Age'];

          $sql = "INSERT INTO people (Name, Age) 
                       VALUES('$Name','$Age');";
          mysqli_query($conn,$sql);
       ?>

0 个答案:

没有答案