0

I want to do multiple delete using href link, how can i done ?

This code generate given below error.

Notice: Undefined index: action in
C:\xampp\htdocs\montu\montu\multiple.php on line 32

Warning: implode() [function.implode]: Invalid arguments passed in
C:\xampp\htdocs\montu\montu\multiple.php on line 32



<body>
    <form method="post" action="<?php $_PHP_SELF ?>">
        <table>
            <tr>
                <td>
                    <input type="checkbox" name="action[]" value="1">1
                </td>
                <td>
                    <input type="checkbox" name="action[]" value="2">2
                </td>
            </tr>
            <tr>
                <td>
                    <a href="?id">Click Me..</a>
                </td>
            </tr>

        </table>
    </form>

<?php 
    if(isset($_REQUEST['id']))
    {
        $action=implode(',',$_REQUEST['action']);//convert array value to string values
        echo $action;
    }
?>
Mayur Prajapati
  • 5,454
  • 7
  • 41
  • 70
Madhusudan
  • 401
  • 3
  • 12
  • 1
    Are you submitting the form? What about using a submit button instead of link. – Sougata Bose Aug 13 '15 at 05:21
  • If you want to use your link for submitting the form, you should take a look at the following question: http://stackoverflow.com/questions/6799533/how-to-submit-a-form-with-javascript-by-clicking-a-link – mario.van.zadel Aug 13 '15 at 05:28

1 Answers1

2

Please try like this..

<?php 
    if(isset($_POST['action']))
    {
        //print_r($_REQUEST);
        $action=implode(',',$_REQUEST['action']);//convert array value to string values
        echo $action;
    }
?>
<body>
    <form name="frm" id="frm" method="post">
        <table>
            <tr>
                <td>
                    <input type="checkbox" name="action[]" value="1">1
                </td>
                <td>
                    <input type="checkbox" name="action[]" value="2">2
                </td>
            </tr>
            <tr>
                <td>
                    <a onclick="document.forms['frm'].submit()" href="#">Click Me..</a>
                </td>
            </tr>

        </table>
    </form>
Hiren Raiyani
  • 754
  • 2
  • 12
  • 28