• We just launched and are currently in beta. Join us as we build and grow the community.

How To Create Multiple Update/Delete Data Using PHP

test0123

Patch Validation Expert
T Rep
0
0
0
Rep
0
T Vouches
0
0
0
Vouches
0
Posts
150
Likes
143
Bits
2 MONTHS
2 2 MONTHS OF SERVICE
LEVEL 1 200 XP
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. </

    table

    >
  30. </

    td

    >
  31. </

    tr

    >
  32. <?php
  33. }
  34. ?>
  35. <tr

    >
  36. <td

    colspan

    =

    "2"

    >
  37. <input

    type

    =

    "submit"

    name

    =

    "submit"

    value

    =

    "Update"

    class

    =

    "btnSubmit"

    >
  38. <a

    href

    =

    "index.php"

    ><input

    type

    =

    "button"

    value

    =

    "Cancel"

    class

    =

    "btnSubmit"

    ></

    a

    >
  39. </

    td

    >
  40. </

    tr

    >
  41. </

    table

    >
  42. </

    form

    >

And, it will look like.

To select multiple data.

1_40.png


To edit multiple data.

2_12.png


To delete multiple data.

3_2.png


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.


Download
You must upgrade your account or reply in the thread to view the hidden content.
 

452,496

338,631

338,639

Top