Results 1 to 4 of 4
  1. #1

    foreach() usage?

    Hi Guys,

    I have a query that gets about 4 rows. In the while() for the query fetch array. I have this:

    echo "<input type=\"checkbox\" name=\"deleterow\" value=\"yes\">";

    How do I say in the foreach that for every one of the checkboxes that is checked, to delete something. I know how to do that, but I just need to know how to say for every row that was checked.

    How do I do it?

  2. #2
    so on the script that processes the form, assuming the checkboxes are named deleterow_1, deleterow_2, etc.
    PHP Code:
    foreach ($_POST as $key => $value)
        if (
    strstr($key'deleterow_') === 0
    && $value == 'yes')
    //delete the row

    or, make value be the number of the row and make the names be deleterow[1], etc then you can just loop thru $_POST['deleterow']
    SkiingYAC Custom Solutions
    system administration, development, design, & hosting

  3. #3
    Join Date
    Mar 2004

    <input type="checkbox" name="deleterow[]" id="deleterow[]" value="yes">


    $array_del = $_POST['deleterow'];

    foreach($array_del as $id){
    echo $id;

    I think that might work (not sure thou)

    Testing 1.. Testing 1..2.. Testing 1..2..3...

  4. #4
    Thankyou both for your replies. I have tested both, and both seem to work. Thanks again.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts