How to update a specific record in mysql from html button

?php
       include ('D_Base_Connect.php');
       $r = "SELECT * FROM userfile WHERE status='Pending'";
      // $query = "SELECT * FROM userfile";
       $rs = mysql_query($r);
       
         while($row = mysql_fetch_array($rs)){
          echo "
          <tr> <form method='post' action='admininterface.php'>
              <td><center>$row[0]</center></td>
              <td><center>$row[1]</center></td>
              <td><center>$row[2]</center></td>
              <td><center>$row[3]</center></td>
              <td><center>$row[4]</center></td>
              <td><center>$row[5]</center></td>
              <td><center>$row[6]</center></td>
              <td><center>$row[7]</center></td>
              <td><center>$row[8]</center></td>
              <td><center>$row[9]</center></td>
              <td><center>$row[10]</center></td>
              <td><center><button type='submit' name='submit'>Mark Received
              </button></td></form></tr>";
            }
              echo "</table>";

?></table>
</body>
</html>

<?php
		if(isset($_POST['mark'])){
			$sr= $_POST['fileid'];
			
				$sql = mysql_query("UPDATE userfile Set status= 'Received' where fileid= '$sr'");
			}
	?>

“fileid” is primary key of Table “userfile” and i want to update the field STATUS from PENDING TO RECEIVED throuh html form , thruough submit button but it giver error that "fileid " not found After I submit the form.

Ask yourself where you are naming the individual form elements. The answer of course is that you are not. You are also making one form per user so ask yourself how you are distinguishing between users. Again the answer is that you are not.

I could probably give you a working example but maybe the above hints will be enough after you research a bit on html forms.

And if you are following a tutorial then drop it. The mysql_ function have been completely removed in PHP 7. Find one that starts with PDO.

im totattly new to php and mysql i dont even know the functions and their working so please help me

I truly wish I could point you to a good Introduction to Web 2017 development using PHP 7+ on the backend resource but I just don’t know of any.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.