ok, ill try to explain again...
HTML FORM.....
(71 different checkbox's, users select whichever ones they want)
each checkbox has a different <input name=""> in this case it starts at 0 and goes to 71 and different Values - which becomes the filename of the txt file we are trying to write on the php side.
.
.
.
PHP SCRIPT.
Gets all $_POST[values] set in the html form - returns an error when a value is unslected, but that gets surpressed by error_reporting(0).
the file writing code i supplied works fine only for the first checkbox, if selected.
PHP Code:
if (!$handle0 = fopen("$dir/$warning0", 'aw+')) {
echo "<br>Cannot open file ($dir/$warning0)";
exit;
}
// Write content to file.
if (fwrite($handle0,"\r\n $rContents") === FALSE) {
echo "<br>Cannot write to file ($dir/$warning0)";
exit;
}
echo "<br>Success, wrote ($rContents) to file ($dir/$warning0)";
chmod("$dir/$warning0", 0777);
fclose($handle0);
now, it works fine beacuse i have got $warning0 ($warning0 is set by..
PHP Code:
for($i=0;$i<71;$i++) {
$warning[$i] = $_POST[''.$i.''];
}
)
so $warning0 = $_POST['0'] through to $warning71 = $_POST['71']
For me to use my file write code properly, i need to change 2 things --> $handle0 and $warning0 - this needs to be changed thorugh to $handle71 and $warning71, and having 71 slightly different versions of the same code makes for a very bulky script.
Hence why i need it to loop 71 times, adding 1 to the value of $handle and $warning (which i can't get it to do) and not halt on an unselected value, but how?
The code supplied in the previous post kinda works, for some reason it writes the same file 4 times over, and also writes unselected values - which is not what i want.
Hopefully u understand this time
