Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Registered User
    Join Date
    Jul 2002
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts

    code for "if check box is checked..."?

    Ok, I created a form and when it submits, it goes to my file info.php... when it goes there I do not want a loop, I want to have an "if" statement for all the checkboxes in the previous html document, but for example, when I try

    if (isset($chkbx1))
    {
    $filedata = implode("",file("searchtest.php"));
    $zipfile -> add_file($filedata, "/dir/file4.txt");
    }

    I recieve a parse error. The reason I do not want a loop is because I can not replace the "/dir/file4.txt" with an array such as $download[$i] and have an i++ in the loop, and have the variables set as something like $download1 = "/dir/file1.txt", $download2 = "/dir/file2.txt". I don't even think that it is possible but if it is could someone help me out with it?

  • #2
    Registered User
    Join Date
    Jul 2002
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Nevermind, got it to work in a loop ^_^ If you are curious and want to see the code, I will post it up here if you reply saying so

  • #3
    New Coder
    Join Date
    Jul 2002
    Posts
    87
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yes please.

  • #4
    Regular Coder
    Join Date
    Jun 2002
    Location
    UK
    Posts
    577
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I assume you just eval()ed a new variable to represent the value of the iterated through checkbox names and associated a named
    zipfile reference if the value was on?

    Would be interesting to see the code though
    Ökii - formerly pootergeist
    teckis - take your time and it'll save you time.

  • #5
    Registered User
    Join Date
    Jul 2002
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts

    hey sorry

    hey guys, sorry I have been away from the board for a little while. Basically with the code I just made the file names, file1, file2, file3, and then for the download site I put "/dir/file$i" the code is as follows:


    <?// use a "for" loop to read and display array elements

    $zipfile = new zipfile();
    $zipfile -> add_dir("dir/");

    for($count = 0; $count < sizeof($download); $count++)
    {
    $filedata = implode("",file("searchtest.php"));
    $zipfile -> add_file($filedata, "/dir/$download[$count].txt");
    echo "$download[$count]"; }

    $filename = "output.zip";
    $fd = fopen ($filename, "wb");
    $out = fwrite ($fd, $zipfile -> file());
    fclose ($fd);

    echo "<a href=\"output.zip\">Click here to download the new zip file.</a> ";}?>


    this actually did a bit of redundancy, you dont need the [$count] if the $download variable is preset to different names, and vice versa, you dont need $download if it is just "file1,file2,file3", you could just have file[$count].txt


  •  

    Posting Permissions

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