|
-
Apr 3rd, 2008, 01:12 PM
#1
Thread Starter
WiggleWiggle
[RESOLVED] Get Parent Folders - Database
Ok, i have a file manager page, and i created a 'move files' page.
This page lists all of the members folders from the database.
Here is the DB structure:
Code:
folderID | parentID | memberID | folder_name | password | sharesetting
1 | 0 | 2 | Test Folder | NULL | 0
2 | 1 | 2 | Test Child Folder | NULL | 0
3 | 1 | 2 | Test Child Folder numeo 2 | NULL | 0
So according to that database, folder 1 is a parent folder shown at ROOT. Folders 2 & 3 are child folders of 1.
What i want to do, is have it so that when it lists all of the members folders it will show it as a Path. EG:
Test Folder
Test Folder / Test Child Folder
Test Folder / Test Child Folder numero 2
But it is not going to be limited to 2 folders. it could be a lot more than that.
My usual boring signature: Something
-
Apr 3rd, 2008, 01:18 PM
#2
-
Apr 3rd, 2008, 01:36 PM
#3
Thread Starter
WiggleWiggle
Re: Get Parent Folders - Database
here is my loop:
PHP Code:
<?php $sql = "SELECT * FROM `folders` WHERE memberID='{$_SESSION['member_id']}'"; $query = mysql_query($sql); ?> <h2>Mass Move Files</h2> Where do you want to move these files?<br> <form action='index.php?do=movedelete&move=1' method='POST'> <input type="hidden" value='<?php print_r($_POST['checkfiles']); ?>' name='checkfiles'> <select name='moveto'> <?php while($row = mysql_fetch_array($query)){ ?> <option value='<?php echo $row['folderID']; ?>'><?php echo $row['folder_name']; ?></option> <?php } ?> </select> <input type='submit' name='submit' value='Move Files!'> </form> <?php
I dont understand what you mean keep getting them.
My usual boring signature: Something
-
Apr 3rd, 2008, 02:08 PM
#4
-
Apr 3rd, 2008, 02:28 PM
#5
Thread Starter
WiggleWiggle
Re: Get Parent Folders - Database
your code is confusing the hell outta me. I have been looking at it for the past 10 minutes trying to figure out how to make it work, and i have no idea what i am doing.
Also, can you use [php] [/php] not [HIGHLIGHT=php] [/highlight]
My usual boring signature: Something
-
Apr 3rd, 2008, 02:29 PM
#6
-
Apr 3rd, 2008, 02:34 PM
#7
Thread Starter
WiggleWiggle
Re: Get Parent Folders - Database
attached... saved as .txt for upload compatibility
go online
Last edited by dclamp; Apr 4th, 2008 at 01:47 PM.
My usual boring signature: Something
-
Apr 4th, 2008, 11:16 AM
#8
-
Apr 4th, 2008, 01:45 PM
#9
Thread Starter
WiggleWiggle
Re: Get Parent Folders - Database
got it to work. with a little modification, it works great
PHP Code:
<?php $sql = "SELECT * FROM `folders` WHERE `memberID`='".$_GET['member_id']."'"; $result = mysql_query($sql) or die($sql); while($row = mysql_fetch_assoc($result)) {
$path = $row['folder_name'];
$parent_id = $row['parentID'];
while ($parent_id != 0) { $sql_parent = "SELECT * from `folders` where `folderID` = '".$parent_id."'"; $result_parent = mysql_query($sql_parent); $row_parent = mysql_fetch_assoc($result_parent); $parent_id = $row_parent['parentID']; $path = $row_parent['folder_name'].' / '.$path; }
echo "Path: ".$path. "<br>"; }
My usual boring signature: Something
-
Apr 4th, 2008, 05:56 PM
#10
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|