Jump to content

Ferdi22

New Members
  • Posts

    3
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Ferdi22's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi Joel24, Thx!! it works!! Here's the code: <?php // Get directory's $permitted = array(); $sql2 = "SELECT url FROM url WHERE gebruiker_id =" . $id . " ORDER BY id ASC"; // Get the directory's in the db from the user $res2 = mysql_query($sql2); while ($rij = mysql_fetch_array($res2)) { $permitted[] = $rij['url']; } $handle = opendir(realpath('../album/Album/.')); while ($direc = readdir($handle)) { //Get the directory's in the Album folder if($direc == '.' || $direc == '..' || $direc == 'res' || $direc == 'manifest.jmf' || $direc == 'lifeboat.zip' || $direc == 'index.html' || $direc == 'folderimage.jpg') { // Exclude some files to show } else { if (in_array($direc, $permitted)) { // When actual directory is the same as the folder $checked = "checked"; } else { $checked = ""; } echo "\t\t<input type='checkbox' name='map[]' id='map[]' value='" . $direc. "' " . $checked . " />" . $direc . "<br />\n"; // Show it! } } closedir($handle); ?> BTW: It must be "if (in_array($direc, $permitted))" and not "if (in_array($permitted, $direc))". Greetings, Ferdi
  2. Hello Joel24, Thx for your fast reply!! Well it didn't work out (yet) My DB: I got a table "Users" and a Table "url" My "url": id user_id url In the "url" are the folders named wich are connected with the user_id and the id from the table "Users" (I hope you understand). This is my code: // Get directory's $handle = opendir(realpath('../album/Album/.')); while ($direc = readdir($handle)) { //Get the directory's in the Album folder $sql2 = "SELECT url FROM url WHERE gebruiker_id =" . $id . " ORDER BY id ASC"; // Get the directory's in the db from the user $res2 = mysql_query($sql2); while ($rij = mysql_fetch_array($res2)) { $url = $rij['url']; if($direc == '.' || $direc == '..' || $direc == 'res' || $direc == 'manifest.jmf' || $direc == 'lifeboat.zip' || $direc == 'index.html' || $direc == 'folderimage.jpg') { // Exclude some files to show } else { if ($direc == $url) { // When actual directory is the same as the folder $checked = "checked"; } else { $checked = ""; } echo "\t\t<input type='checkbox' name='map[]' id='map[]' value='" . $direc. "' " . $checked . " />" . $direc . "<br />\n"; // Show it! } } } closedir($handle); ?> My output is: <input type='checkbox' name='map[]' id='map[]' value='050218_Rai_auto' checked />050218_Rai_auto<br /> <input type='checkbox' name='map[]' id='map[]' value='050218_Rai_auto' />050218_Rai_auto<br /> <input type='checkbox' name='map[]' id='map[]' value='050218_Rai_auto' />050218_Rai_auto<br /> <input type='checkbox' name='map[]' id='map[]' value='050218_Rai_auto' />050218_Rai_auto<br /> <input type='checkbox' name='map[]' id='map[]' value='050218_Rai_auto' />050218_Rai_auto<br /> <input type='checkbox' name='map[]' id='map[]' value='050304 Citroen' />050304 Citroen<br /> <input type='checkbox' name='map[]' id='map[]' value='050304 Citroen' checked />050304 Citroen<br /> <input type='checkbox' name='map[]' id='map[]' value='050304 Citroen' />050304 Citroen<br /> <input type='checkbox' name='map[]' id='map[]' value='050304 Citroen' />050304 Citroen<br /> <input type='checkbox' name='map[]' id='map[]' value='050304 Citroen' />050304 Citroen<br /> <input type='checkbox' name='map[]' id='map[]' value='050429 Matiz' />050429 Matiz<br /> <input type='checkbox' name='map[]' id='map[]' value='050429 Matiz' />050429 Matiz<br /> <input type='checkbox' name='map[]' id='map[]' value='050429 Matiz' checked />050429 Matiz<br /> <input type='checkbox' name='map[]' id='map[]' value='050429 Matiz' />050429 Matiz<br /> <input type='checkbox' name='map[]' id='map[]' value='050429 Matiz' />050429 Matiz<br /> <input type='checkbox' name='map[]' id='map[]' value='BMW M3' />BMW M3<br /> <input type='checkbox' name='map[]' id='map[]' value='BMW M3' />BMW M3<br /> <input type='checkbox' name='map[]' id='map[]' value='BMW M3' />BMW M3<br /> <input type='checkbox' name='map[]' id='map[]' value='BMW M3' checked />BMW M3<br /> <input type='checkbox' name='map[]' id='map[]' value='BMW M3' />BMW M3<br /> <input type='checkbox' name='map[]' id='map[]' value='Honda Legend 2000' />Honda Legend 2000<br /> <input type='checkbox' name='map[]' id='map[]' value='Honda Legend 2000' />Honda Legend 2000<br /> <input type='checkbox' name='map[]' id='map[]' value='Honda Legend 2000' />Honda Legend 2000<br /> <input type='checkbox' name='map[]' id='map[]' value='Honda Legend 2000' />Honda Legend 2000<br /> <input type='checkbox' name='map[]' id='map[]' value='Honda Legend 2000' checked />Honda Legend 2000<br /> <input type='checkbox' name='map[]' id='map[]' value='Honda Legend 2004' />Honda Legend 2004<br /> <input type='checkbox' name='map[]' id='map[]' value='Honda Legend 2004' />Honda Legend 2004<br /> <input type='checkbox' name='map[]' id='map[]' value='Honda Legend 2004' />Honda Legend 2004<br /> <input type='checkbox' name='map[]' id='map[]' value='Honda Legend 2004' />Honda Legend 2004<br /> <input type='checkbox' name='map[]' id='map[]' value='Honda Legend 2004' />Honda Legend 2004<br /> <input type='checkbox' name='map[]' id='map[]' value='Honda Legend 3.2' />Honda Legend 3.2<br /> <input type='checkbox' name='map[]' id='map[]' value='Honda Legend 3.2' />Honda Legend 3.2<br /> <input type='checkbox' name='map[]' id='map[]' value='Honda Legend 3.2' />Honda Legend 3.2<br /> <input type='checkbox' name='map[]' id='map[]' value='Honda Legend 3.2' />Honda Legend 3.2<br /> <input type='checkbox' name='map[]' id='map[]' value='Honda Legend 3.2' />Honda Legend 3.2<br /> As you can see the directory's "050218_Rai_auto", "050304 Citroen", "050429 Matiz", "BMW M3" and "Honda Legend 2000" are permitted. The directory's "Honda Legend 2004" and "Honda Legend 3.2" are not permitted (This user cannot see these directory's). This is ok! But why this long list?? I can't figure it out. Because every directory is printed 5 times it would be in the second while loop... (User is permitted to acces 5 directory's). How can I just print is one time as: <input type='checkbox' name='map[]' id='map[]' value='050218_Rai_auto' checked />050218_Rai_auto<br /> <input type='checkbox' name='map[]' id='map[]' value='050304 Citroen' checked />050304 Citroen<br /> <input type='checkbox' name='map[]' id='map[]' value='050429 Matiz' checked />050429 Matiz<br /> <input type='checkbox' name='map[]' id='map[]' value='BMW M3' checked />BMW M3<br /> <input type='checkbox' name='map[]' id='map[]' value='Honda Legend 2000' checked />Honda Legend 2000<br /> <input type='checkbox' name='map[]' id='map[]' value='Honda Legend 2004' />Honda Legend 2004<br /> <input type='checkbox' name='map[]' id='map[]' value='Honda Legend 3.2' />Honda Legend 3.2<br /> Any tips are more than welcome! Greetings, Ferdi
  3. Hello, Sorry for my english... Well, I make a smaill website. members has to login and then member can see pictures (saved in a folder). When the admin upload pictures a folder wil be created. To get the actual folders in the "album" folder I use this code. <?php //get the folders $handle = opendir(realpath('../album/Album/.')); while ($direc = readdir($handle)) { if($direc == '.' || $direc == '..') continue; else { echo "\t\t<input type='checkbox' name='map[]' id='map[]' value='" . $direc. "' />" . $direc . "<br />\n"; } } closedir($handle); ?> The admin has to assign the folders wich are allowed to see by a member. I use checkboxes for that. And now my problem: When a member can see folder 1 to 4 and the admin upload 2 new folders and want to give that member to see these 2 new folders I want the following: 6 checkboxes (checkbox 1 > album 1, checkbox 2 > album 2... etc). As is said, this member can see folder 1 to 4, so in the CMS album 1 to 4 has to be checked ans album 5 to 6 not. This is my code for that: <?php $sql2 = "SELECT url FROM url WHERE gebruiker_id =" . $_GET['id'] . " ORDER BY url ASC"; $res2 = mysql_query($sql2); while ($rij = mysql_fetch_array($res2)) { $url = $rij['url']; // mappen ophalen $handle = opendir(realpath('../album/Album/.')); while ($direc = readdir($handle)) { if($direc == '.' || $direc == '..' || $direc == $url) { continue; } echo "\t\t<input type='checkbox' name='map[]' id='map[]' value='" . $direc. "' />" . $direc . "<br />\n"; } closedir($handle); } ?> Now my output is: <input type='checkbox' name='map[]' id='map[]' value='album 2' />album 2<br /> <input type='checkbox' name='map[]' id='map[]' value='album 3' />album 3<br /> <input type='checkbox' name='map[]' id='map[]' value='album 4' />album 4<br /> <input type='checkbox' name='map[]' id='map[]' value='album 5' />album 5<br /> <input type='checkbox' name='map[]' id='map[]' value='album 6' />album 6<br /> <input type='checkbox' name='map[]' id='map[]' value='album 1' />album 1<br /> <input type='checkbox' name='map[]' id='map[]' value='album 2' />album 2<br /> <input type='checkbox' name='map[]' id='map[]' value='album 4' />album 4<br /> <input type='checkbox' name='map[]' id='map[]' value='album 5' />album 5<br /> <input type='checkbox' name='map[]' id='map[]' value='album 6' />album 6<br /> <input type='checkbox' name='map[]' id='map[]' value='album 1' />album 1<br /> <input type='checkbox' name='map[]' id='map[]' value='album 2' />album 2<br /> <input type='checkbox' name='map[]' id='map[]' value='album 3' />album 3<br /> <input type='checkbox' name='map[]' id='map[]' value='album 5' />album 5<br /> <input type='checkbox' name='map[]' id='map[]' value='album 6' />album 6<br /> What do I have to do to check the checkboxes (album 1-4) and not to check the album 5-6??? My guess it has to do with the While in While loop but... Greetings, Ferdi
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.