Updating Using Radio Button - Checkbox and Dropdown List

In this tutorial I will you will learn about updates and how to save data in Mysql , display the information from MySQL, and most important How to update radio button, Checkbox and dropdown list in PHP and MySQL.This simple updating using radio button, checkbox and dropdown list in PHP and MySQL. This project creates a registration query through the form and automatically connect in the mysql to create database. And you can update and delete the data even if you are not in the database. I will show you the example code below.

Sample Code

Registration Form
  1. <script type="text/javascript">
  2. function deletes(id)
  3. {
  4.     if(confirm('Sure To Remove This Record ?'))
  5.     {
  6.                 window.location.href='delete.php?id='+id;
  7.     }
  8. }
  9. </script>
  10. <h1 align="center">Update - Registration Form</h1>
  11. <?php
  12. include('config.php');
  13.  
  14. extract($_POST);
  15. if(isset($save))
  16. {
  17.         $que=mysql_query("select email from student where email='$email'");
  18.         $row=mysql_num_rows($que);
  19. if($row)
  20. {
  21. echo "<font color='red'>This email id is  alredy exists</font>";
  22. }
  23. else
  24.         {
  25.         $hob=implode(",",$arr);
  26.         mysql_query("insert into student values('','$n','$e','$m','$gen','$hob','$cou',now())");
  27. echo "<font color='blue'>Records saved</font>";
  28.         }
  29. }
  30. echo "<table border='1'>";
  31. echo "<tr><th>Student_Id</th><th>Name</th><th>Email</th><th>Mobile Number</th><th>Gender</th><th>Hobbies</th><th>Country</th><th>Registered Date</th><th>Delete</th><th>Update</th></tr>";     
  32.         $que = mysql_query("select *  from student");
  33. while($obj=mysql_fetch_object($que))
  34.         {
  35. echo "<tr>";
  36. echo "<td>".$obj->id."</td>";
  37. echo "<td>".$obj->name."</td>";
  38. echo "<td>".$obj->email."</td>";
  39. echo "<td>".$obj->mob."</td>";
  40. echo "<td>".$obj->gender."</td>";
  41. echo "<td>".$obj->hobbies."</td>";
  42. echo "<td>".$obj->country."</td>";
  43. echo "<td>".$obj->regDate."</td>";
  44. ?>
  45.         <td><a href="javascript:deletes(<?php echo $obj->id; ?>)">Delete</a></td>
  46. <?php
  47. echo "<td><a href='update.php?eid=$obj->email'>Update</a> &nbsp;</td>";
  48.        
  49. echo "</tr>";
  50.         }
  51. echo "</table>";
  52. ?>
Update - Registration Form
Name
Email
Mobile Number
Gender Male Female
Your Hobbies Programming Coding Editing
Select Your Country
Database Configuration
  1. <?php
  2.         $con=mysql_connect("localhost","root","") or die(mysql_error());
  3. mysql_select_db("radiodown",$con);
  4. ?>
Result For more tutorials just visit this website @www.sourcecodester.com and don't forget to Like and Share. Enjoy Coding.

Add new comment