...

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

conozco345
07-26-2002, 03:52 PM
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?

conozco345
07-28-2002, 05:49 AM
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

EthanX
08-08-2002, 08:55 PM
Yes please.

Ökii
08-09-2002, 10:37 AM
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 :)

conozco345
08-14-2002, 05:42 PM
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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum