title: how to solve Undefined offset: error in php
body: <p>I have a html code where I create a table and two radio button on each row. for giving different name to radio button on each row I used while loop and I++ way.
  that is </p>
  
  <pre><code>&lt;form action = "submit_varification.php" method = "POST" onclick = "return validate()"&gt;
  
                          &lt;div style="position: absolute; left: 50px; top: 90px;"&gt;
                          &lt;label class="right"&gt;&lt;font color="white"&gt;Date:&lt;/font&gt;&lt;/label&gt;
                          &lt;input type="text" id = "frmDate"  /&gt;&lt;br&gt;
                          &lt;p id="date"&gt;&lt;/p&gt;
                          &lt;/div&gt;
                          &lt;div style="position: absolute; left: 250px; top: 91px;"&gt;
                          &lt;label class="right"&gt;&lt;font color="white"&gt;V-ID:&lt;/font&gt;&lt;/label&gt;
                          &lt;input type="text" id = "myText" name = "reviewer" value = ""/&gt;&lt;br&gt;
                          &lt;/div&gt;
                          &lt;div style="position: absolute; left: 900px; top: 91px;"&gt;
                          &lt;button type="button" name="show" id="show" onclick = "" &gt;History&lt;/button&gt;
                          &lt;/div&gt;
                          &lt;div style="position: absolute; left: 900px;"&gt;
                          &lt;input type="submit" name="test" id="test" value="Submit"  /&gt;&lt;br/&gt;
                          &lt;/div&gt;
  
                      &lt;script&gt;
                      var date = new Date();
  
                      document.getElementById("frmDate").value = (date.getMonth() + 1) + '/' + date.getDate() + '/' + date.getFullYear();
  
                      &lt;/script&gt;
                  &lt;/body&gt;
                  &lt;table style="position: absolute; width:95%; left: 20px; top: 150px;" id = "table1"&gt;
                      &lt;?php
                      $myDate = date('m/d/Y');
                      ?&gt;
                          &lt;tr&gt;
                          &lt;th&gt;Date&lt;/th&gt;
                          &lt;th&gt;Time&lt;/th&gt; 
                          &lt;th&gt;Alias&lt;/th&gt;
                          &lt;th&gt;Machine_Name&lt;/th&gt;
                          &lt;th&gt;Build_Name&lt;/th&gt;
                          &lt;th&gt;Build_version&lt;/th&gt;
                          &lt;th&gt;WinDBG&lt;/th&gt;
                          &lt;th&gt;.Net_Framework&lt;/th&gt;
                          &lt;th&gt;Status&lt;/th&gt;
                          &lt;/tr&gt;
                          &lt;?php
                              //get records from database
                              $sql3 = "SELECT * FROM data WHERE `Date` = '".$myDate."' ORDER BY id DESC";
                              $query = $conn-&gt;query($sql3);
                              if($query-&gt;num_rows &gt; 0){
                              $i = 0 ;
                              while($row = $query-&gt;fetch_assoc()){ ?&gt;
                              &lt;tr&gt; 
                              &lt;td&gt;&lt;?php echo $row['Date']; ?&gt;&lt;/td&gt;
                              &lt;td&gt;&lt;?php echo $row['Time']; ?&gt;&lt;/td&gt;
                              &lt;td&gt;&lt;?php echo $row['Alias']; ?&gt;&lt;/td&gt;
                              &lt;td&gt;&lt;?php echo $row['Machine_Name']; ?&gt;&lt;/td&gt;
                              &lt;td&gt;&lt;?php echo $row['Build_Name']; ?&gt;&lt;/td&gt;
                              &lt;td&gt;&lt;?php echo $row['Build_Version']; ?&gt;&lt;/td&gt;
                              &lt;td&gt;&lt;?php echo $row['WinDBG']; ?&gt;&lt;/td&gt;
                              &lt;td&gt;&lt;?php echo $row['.NET_Framework']; ?&gt;&lt;/td&gt; 
                              &lt;td style='white-space: nowrap'&gt;&lt;form&gt;&lt;label class = "ready"&gt;&lt;input type="radio" name="[&lt;?php $i ?&gt;]" value = "Ready"&gt;Ready&lt;/label&gt;&lt;label class = "notready"&gt;&lt;input type="radio" name="[&lt;?php $i ?&gt;]" value = "Not Ready" &gt;Not Ready&lt;/label&gt;&lt;/form&gt;&lt;/td&gt;
                              &lt;/tr&gt; 
  
                              &lt;?php $i++ ; } } ?&gt;
  
  
                          &lt;/table&gt;
  
  
                          &lt;/form&gt;
  </code></pre>
  
  <p>and I want to store the value of each row to a database. so I used POST method on the form. and I am trying to take the value of radio button to database but I am facing a error like </p>
  
  <pre><code> Notice: Undefined offset: 0 in C:\wamp64\www\submit_varification.php on line 33
  Notice: Undefined offset: 1 in C:\wamp64\www\submit_varification.php on line 33
  Notice: Undefined offset: 2 in C:\wamp64\www\submit_varification.php on line 33
  </code></pre>
  
  <p>and the PHP code:  </p>
  
  <pre><code>$query = $conn-&gt;query($sql4);
                          if($query-&gt;num_rows &gt; 0){
                          $i = 0 ;    
                          while($row = $query-&gt;fetch_assoc()){
  
  
                              //...insert into your DB.
                          $row1 = $row["Date"];
                          $row2 = $row["Time"];
                          $row3 = $row["Alias"];
                          $row4 = $row["Machine_Name"];
                          $row5 = $row["Build_Name"];
                          $row6 = $row['Build_Version'];
                          $row7 = $row["WinDBG"];
                          $row8 = $row[".NET_Framework"];
  
                          $status = $_POST["$i"]; // this is the error
  
  
                          $sql5 = "INSERT INTO history (`Date`, `Time`, `Alias`, `Machine_Name`, `Build_Name`, `Build_version`, `WinDBG`, `.NET_Framework`, `Status`, `Reviewed_By`) 
                          VALUES ('".$row1."','".$row2."','".$row3."','".$row4."','".$row5."','".$row6."','".$row7."','".$row8."', '".$status."', '".$reviewer."') ";
                          if ($conn-&gt;query($sql5) === TRUE) {
                          //echo "New record created successfully";
                          //echo nl2br("\n");
                          echo "";
  
                          } else {
                          echo "Error: " . $sql5 . "&lt;br&gt;" . $conn-&gt;error;
                          }
  
                          $i++ ; 
                          }
                          }   
  </code></pre>
  
  <p>is anyone have any solution for this ?</p>