Here's an example of the code...
Code: Select all
File1.jpg
Select the users that have access to the above file:
<input type="checkbox" name="access[file1]" value="user1"> Ben
<input type="checkbox" name="access[file1]" value="user2"> Peter
File2.jpg
Select the users that have access to the above file:
<input type="checkbox" name="access[file2]" value="user1"> Ben
<input type="checkbox" name="access[file2]" value="user2"> Peter
File3.jpg
Select the users that have access to the above file:
<input type="checkbox" name="access[file3]" value="user1"> Ben
<input type="checkbox" name="access[file3]" value="user2"> PeterThe problem is, if I check both the access[file*] check boxes, because they are named the same, it only reads the second value... If I select both the access[file*] check boxes, I need it to give me the two I've selected for the same file.
Am I making sense?
I've tried a number of ways of laying the form fields out but none seem to give me my desired result... Maybe I'm doing something wrong in my foreach functoin
Code: Select all
<input type="checkbox" name="access[file3][user1]" value="user1">
<input type="checkbox" name="access[user1][file3]" value="user1">
<input type="checkbox" name="access[user1]" value="[file3]">Code: Select all
foreach ($_POST[fileaccess] as $user_id => $file_id) {
echo "$user_id --- $file_id<br>";
}