mysql/php loop with multiple forms or just one?

user2965311

i've looked around and did no find an answer to a question that has been bugging me for quite some time. let's say i have a mysql table with tasks. in php i loop through all the records and display them. each row should have buttons e.g. "done", "delete", etc. which will trigger an action (preferably with ajax).

now the question is, should i do this with multiple forms or just with one? is there a best practice for that? are there considerable advantages/disadvantages for each of the options?

i did search on this site, so my apologies in advance, should i have missed a post explaining just that.

thanks a lot in advance

Neil

This is how I would write it. I don't see the need for forms. I think forms might slightly over complicate the process.

<ul>
    <li mysqlId="0">Name <button class="done">Done</button> <button class="delete">Delete</button></li>
    <li mysqlId="1">Name <button class="done">Done</button> <button class="delete">Delete</button></li>
</ul>

<script>
    $(".done").click(function () {
        mysqlId = $(this).parents("li:first").attr("mysqlId");
        $.post(/* ajax magic */);
    });

    $(".delete").click(function () {
        mysqlId = $(this).parents("li:first").attr("mysqlId");
        $.post(/* ajax magic */);
    });
</script>

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Java

How can you get a multiple output in json in just one loop?

From Dev

Is there a way to create just ONE NuGet package that will target multiple project types (web forms, MVC, etc.)?

From Dev

Replacing multiple spaces into just one?

From Dev

Multiple await operations or just one

From Dev

Multiple replacement with just one regex

From Dev

Multiple inputs with just one Setter

From Dev

validation for multiple forms generated by loop?

From Dev

Multiple forms on one MVC form, created with a loop, only the first submits data

From Dev

Multiple update forms for one model

From Dev

Multiple Login Forms On One Page

From Dev

Clear multiple forms on one page

From Dev

For loop returning just one output in R

From Dev

C can not loop just one time

From Dev

Multiple arrays in one loop

From Dev

Rails one model multiple forms one page

From Dev

Multiple servlets, or just one main controller

From Dev

Multiple publishers in a session, how subscribe to just one?

From Dev

Coffeescript changes class for all radio forms instead of for just the one that was changed

From Dev

jQuery Multiple Dynamic Forms + Foreach Loop

From Dev

How to register multiple fields from a loop in a forms?

From Dev

Ubuntu One Sync for multiple folders in Windows, not just the Ubuntu One folder

From Dev

Ubuntu One Sync for multiple folders in Windows, not just the Ubuntu One folder

From Dev

Reform gem: use one model for multiple forms

From Dev

AngularJS - multiple forms - one ng-model?

From Dev

Send multiple forms data on one page with ajax

From Dev

How to handle multiple forms in one page

From Dev

Having issues with multiple forms in one page in php

From Dev

Using one javascript function for multiple forms

From Dev

Using one script for multiple forms on a single page

Related Related

  1. 1

    How can you get a multiple output in json in just one loop?

  2. 2

    Is there a way to create just ONE NuGet package that will target multiple project types (web forms, MVC, etc.)?

  3. 3

    Replacing multiple spaces into just one?

  4. 4

    Multiple await operations or just one

  5. 5

    Multiple replacement with just one regex

  6. 6

    Multiple inputs with just one Setter

  7. 7

    validation for multiple forms generated by loop?

  8. 8

    Multiple forms on one MVC form, created with a loop, only the first submits data

  9. 9

    Multiple update forms for one model

  10. 10

    Multiple Login Forms On One Page

  11. 11

    Clear multiple forms on one page

  12. 12

    For loop returning just one output in R

  13. 13

    C can not loop just one time

  14. 14

    Multiple arrays in one loop

  15. 15

    Rails one model multiple forms one page

  16. 16

    Multiple servlets, or just one main controller

  17. 17

    Multiple publishers in a session, how subscribe to just one?

  18. 18

    Coffeescript changes class for all radio forms instead of for just the one that was changed

  19. 19

    jQuery Multiple Dynamic Forms + Foreach Loop

  20. 20

    How to register multiple fields from a loop in a forms?

  21. 21

    Ubuntu One Sync for multiple folders in Windows, not just the Ubuntu One folder

  22. 22

    Ubuntu One Sync for multiple folders in Windows, not just the Ubuntu One folder

  23. 23

    Reform gem: use one model for multiple forms

  24. 24

    AngularJS - multiple forms - one ng-model?

  25. 25

    Send multiple forms data on one page with ajax

  26. 26

    How to handle multiple forms in one page

  27. 27

    Having issues with multiple forms in one page in php

  28. 28

    Using one javascript function for multiple forms

  29. 29

    Using one script for multiple forms on a single page

HotTag

Archive