SitePoint Sponsor

User Tag List

Results 1 to 1 of 1

Hybrid View

  1. #1
    SitePoint Enthusiast
    Join Date
    Dec 2006
    0 Post(s)
    0 Thread(s)

    [resolved]help using arrays in forms


    probs an easy one, my understanding is just a little fuzzy in this area.

    Basically i'm printing out a list of headlines for a news page, each with a checkbox next to them so you can check all the entries you want to delete and click the delete button and it deletes them all.

    I'm just not entirely sure how to send the $_POST values in the form to make an array of id's that my code can interpret and delete.

    in my form I have code generated something like this
    <input name=\"checkdelete[]\" type=\"checkbox\" value=\"$id\"/>
    in a while statement, created for each header.

    Then in my delete code i have

    $idarray = array();
    if (!isset($_POST['checkdelete'])){
    	$idarray[] = $_GET['id'];
    	$idarray[] = $_POST['checkdelete'];
    // Delete the news
    for($i=0; $i<count($idarray); $i++){
    	$id = $idarray[$i];
    The $_GET is for the alternative way of deleting single entries that already exists.

    using a tamper I see that the form is sending the multiple POST values for checkdelete, but the PHP doesn't seem to be breaking it apart into an array properly?

    Your help is greatly appreaciated.

    EDIT: I realise now that I was putting the array inside the array. thanks anyway
    Last edited by LetterAfterZ; Aug 16, 2007 at 20:04.


Posting Permissions

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