title: Modify a value on a PHP/mysql table and update the table on the server
body: <p>I have a table with football matches and predictions.</p>
  
  <pre><code>| ID | home_team | home_result | away_team | away_result | date&amp;time | location
  </code></pre>
  
  <p>I can show the table on php but how can i use this table to update "home result" and "away result" on the server? and how can i disable this fields after the match started?</p>
  
  <p>This code works fine but I can't modify local and away results from this. I would like to do something like <a href="https://i.stack.imgur.com/JvFS5.jpg" rel="nofollow noreferrer">this</a>:</p>
  
  <p><img src="https://i.stack.imgur.com/JvFS5.jpg" alt=""></p>
  
  <p>**Update Code working</p>
  
  <pre><code> &lt;html&gt; 
   &lt;head&gt;&lt;/head&gt; 
   &lt;body&gt; 
   &lt;/form&gt; 
   &lt;form action="pruebalista.php" method="post" name="groups" &gt;  
   &lt;select name="value"&gt;  
      &lt;option value="All"&gt;All&lt;/option&gt; 
      &lt;option value="A"&gt;A&lt;/option&gt;  
      &lt;option value="B"&gt;B&lt;/option&gt;  
      &lt;option value="C"&gt;C&lt;/option&gt;  
       &lt;option value="D"&gt;D&lt;/option&gt;  
      &lt;option value="E"&gt;E&lt;/option&gt;  
      &lt;option value="F"&gt;F&lt;/option&gt;  
       &lt;option value="G"&gt;G&lt;/option&gt;  
      &lt;option value="H"&gt;H&lt;/option&gt;  
         &lt;/select&gt;  
   &lt;br /&gt;  
   &lt;input type='submit' value = 'Filter'&gt;  
   &lt;/form&gt; 
  
  
  
  &lt;?php  
  //connect to database, checking, etc  
  $con=mysqli_connect("localhost","admin","password","world_cup");
  
  // Check connection
  if (mysqli_connect_errno())
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }
  
  // process form when posted 
  if(isset($_POST['value'])) { 
  if($_POST['value'] == 'All') { 
  
     $query = "SELECT * FROM matches";   
  }   
  else {   
  
      $value=$_POST['value'];
      $query = "SELECT * FROM matches WHERE Group='$value'";   
      }
   } else {   
      // query to get all records   
       $query = "SELECT * FROM partidos ORDER BY Group";   
   }
  
  
  $sql = mysqli_query($con,$query); 
  $count=mysqli_num_rows($sql); 
  ?&gt;
  
  &lt;form action="update.PHP" method="post" name="update" &gt;   
  
  &lt;?php
  
  echo "&lt;table border='3'&gt;
  &lt;tr&gt;
  &lt;th&gt;ID&lt;/th&gt;
  &lt;th&gt;Grupo&lt;/th&gt;
  &lt;th&gt;Local&lt;/th&gt;
  &lt;th&gt;Resultado_local&lt;/th&gt;
  &lt;th&gt;Visitante&lt;/th&gt;
  &lt;th&gt;Resultado_visitante&lt;/th&gt;
  &lt;th&gt;Hora&lt;/th&gt;
  &lt;th&gt;Sede&lt;/th&gt;
  &lt;/tr&gt;";
  
  
  while ($row = mysqli_fetch_array($sql)){      
           ?&gt;
          &lt;input name="id[]" type="hidden" value="&lt;?php echo $row['ID']; ?&gt;"&gt;
          &lt;?php            
          echo "&lt;tr&gt;";
          echo "&lt;td valign=middle align=center width=auto&gt;" . $row['ID'] . "&lt;/td&gt;";
          echo "&lt;td valign=middle align=center width=auto&gt;" . $row['Group'] . "&lt;/td&gt;";
          echo "&lt;td valign=middle align=center width=auto&gt;" . $row['home'] . "&lt;/td&gt;";
          if ($row['Disabled'] === '1'){
          echo "&lt;td valign=middle align=center width=auto&gt; &lt;input type='text' name='home_res[]' disabled value='". $row['Resultado_local'] . "'/&gt;&lt;/td&gt;";
         echo "&lt;td valign=middle align=center width=auto&gt; &lt;input type='text'  name='away_res[]' disabled value='". $row['Resultado_visitante'] . "'/&gt;&lt;/td&gt;";&lt;/td&gt;";
  
          }
          else{
          echo "&lt;td valign=middle align=center width=auto&gt; &lt;input type='text' name='home_res[]' value='". $row['Resultado_local'] . "'/&gt;&lt;/td&gt;";
          echo "&lt;td valign=middle align=center width=auto&gt; &lt;input type='text'  name='away_res[]' value='". $row['Resultado_visitante'] . "'/&gt;&lt;/td&gt;";&lt;/td&gt;";
  
          }
  
          echo "&lt;td valign=middle align=center width=auto&gt;" . $row['Visitante'] . "&lt;/td&gt;";
  
          echo "&lt;td valign=middle align=center width=auto&gt;" . $row['Time'] . "&lt;/td&gt;";
          echo "&lt;td valign=middle align=center width=auto&gt;" . $row['city'] . "&lt;/td&gt;";
          echo "&lt;/tr&gt;";
  } 
  mysqli_close($con);  
  
  echo "&lt;/table&gt;";
  ?&gt; 
  &lt;input type='submit' value ='update'&gt;  
  &lt;/form&gt;
  
  &lt;/body&gt; 
  &lt;/html&gt;
  </code></pre>
  
  <p>Finally I decided to use update.php. This is the code:</p>
  
  <pre><code> &lt;?php
  
   include 'pruebalista.php';
  
   // Connect to server and select database. 
  
  //connect to database, checking, etc  
  $con=mysqli_connect("192.168.36.251","kpsadmin","Bicentenario","mundial");
  
  // Check connection
  if (mysqli_connect_errno())
  {
   echo "Failed to connect to MySQL: " . mysqli_connect_error();
   }
  
  // find out how many records there are to update 
  //$size = count($_POST['away_res']); 
   $size = count($_POST['home_res']); 
  
  // start a loop in order to update each record 
  $i = 0; 
  while ($i &lt; $size) { 
  // define each variable 
  $home = $_POST['home_res'][$i]; 
  $away= $_POST['away_res'][$i]; 
  $id = $_POST['id'][$i]; 
  
  
   // do the update and print out some info just to provide some visual feedback 
   $query = "UPDATE $tabla SET `Home_result`='$home', `Away_result`='$away' WHERE   `ID`='$id'"; 
   mysqli_query($con , $query) or die ("Error in query: $query"); 
  
   ++$i; 
  
   } 
   header("location: pruebalista.php");
   mysqli_close($con);
   ?&gt; 
  </code></pre>