How To Create Multiple Update/Delete Data Using PHP

Submitted by: 
Language: 
Visitors have accessed this post 1313 times.

If you are looking for on How To Create Multiple Update/Delete Data Using PHP then you are at the right place. We all know about on how to update data and deleting data one by one. In this article, we can update and delete data in the selecting rows that you want.

To select multiple rows to update and deleting data, we used a checkbox to select the multiple data.

Form Field - Multiple SelectEdit Data

This source code that the user can edit their multiple data in the rows.

  1. <form name="frmUser" method="post" action="">
  2. <table border="0" cellpadding="10" cellspacing="0" width="500" align="center">
  3. <tr class="tableheader">
  4. <td>Edit User</td>
  5. </tr>
  6. <?php
  7. $rowCount = count($_POST["users"]);
  8. for($i=0;$i<$rowCount;$i++) {
  9. $result = mysql_query("SELECT * FROM users WHERE userId='" . $_POST["users"][$i] . "'");
  10. $row[$i]= mysql_fetch_array($result);
  11. ?>
  12. <tr>
  13. <td>
  14. <table border="0" cellpadding="10" cellspacing="0" width="500" align="center" class="tblSaveForm">
  15. <tr>
  16. <td><label>Username</label></td>
  17. <td><input type="hidden" name="userId[]" class="txtField" value="<?php echo $row[$i]['userId']; ?>"><input type="text" name="userName[]" class="txtField" value="<?php echo $row[$i]['userName']; ?>"></td>
  18. </tr>
  19. <tr>
  20. <td><label>Password</label></td>
  21. <td><input type="password" name="password[]" class="txtField" value="<?php echo $row[$i]['password']; ?>"></td>
  22. </tr>
  23. <td><label>First Name</label></td>
  24. <td><input type="text" name="firstName[]" class="txtField" value="<?php echo $row[$i]['firstName']; ?>"></td>
  25. </tr>
  26. <td><label>Last Name</label></td>
  27. <td><input type="text" name="lastName[]" class="txtField" value="<?php echo $row[$i]['lastName']; ?>"></td>
  28. </tr>
  29. </td>
  30. </tr>
  31. <?php
  32. }
  33. ?>
  34. <tr>
  35. <td colspan="2">
  36. <input type="submit" name="submit" value="Update" class="btnSubmit">
  37. <a href="index.php"><input type="button" value="Cancel" class="btnSubmit"></a>
  38. </td>
  39. </tr>
  40. </form>

And, it will look like.

To select multiple data.

Select

To edit multiple data.

Edit

To delete multiple data.

Delete

Share us your thoughts and comments below. Thank you so much for dropping by and reading this tutorial post. For more updates, don’t hesitate and feel free to visit this website more often and please share this with your friends or email me at [email protected]. Practice Coding. Thank you very much.


Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • You may insert videos with [video:URL]
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd> <table> <tr> <td> <th> <img> <h1> <h2> <h3> <iframe> [video]
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <asp>, <c>, <cpp>, <csharp>, <css>, <html4strict>, <java>, <javascript>, <mysql>, <php>, <python>, <sql>, <vb>, <vbnet>. The supported tag styles are: <foo>, [foo].
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.