Results 1 to 10 of 15
-
23rd Dec 2010, 09:57 PM #1OPMember
PHP List Hierarchy
Can you suggest how I output these to an expanding/collapsing hierarchy?
Example: http://jqueryui.com/demos/accordion/
Although the accordian is great, it wont work unless I output the html correctly which i'm finding very hard to do.
Here is the page with my current code: http://filewi.re/releases.php
And the code itself: http://code.google.com/p/filewire/so...s/releases.php
This is hours of mental torture so it's a lil messy. Thanks.theforumdrunk Reviewed by theforumdrunk on . PHP List Hierarchy http://lulzimg.com/i02/13ed837b.png Can you suggest how I output these to an expanding/collapsing hierarchy? Example: http://jqueryui.com/demos/accordion/ Although the accordian is great, it wont work unless I output the html correctly which i'm finding very hard to do. Here is the page with my current code: http://filewi.re/releases.php And the code itself: http://code.google.com/p/filewire/source/browse/trunk/includes/releases.php Rating: 5
-
23rd Dec 2010, 10:03 PM #2The Wise OneWebsite's:
twilight.ws ddlrank.comFirst of all you have your query above the table:
PHP Code:$get = mysql_query("SELECT * FROM releases ORDER BY whateveryouwant");
PHP Code:<table>
// Head of the table like ID, name, etc goes here
<?php
while($row = mysql_fetch_object($get)){
?>
<tr>
<td><?php echo $row->id; ?></td>
<td><?php echo $row->name; ?></td>
...
</tr>
<?php
}
?>
</table>, just the stuff you need
I can always be contacted by sending a tweet @twilightws
-
23rd Dec 2010, 10:08 PM #3OPMember
Thanks whoo, no problem with that. It's more the actual process of finding who belongs to whos parent (check db pic). Then displaying them in the right higherarchy.
-
23rd Dec 2010, 10:16 PM #4The Wise OneWebsite's:
twilight.ws ddlrank.comIt's just a matter of thinking:
First you have to select all the parents, then for each parent, you print it, grab the children and print them too...
And after that you just do like I told you:
PHP Code:<table>
// Head of the table like ID, name, etc goes here
<?php
$get = mysql_query("SELECT * FROM tablename WHERE parent = 0 ORDER BY whateveryouwant");
while($parent = mysql_fetch_object($get)){
$get2 = mysql_query("SELECT * FROM tablename WHERE parent = $parent->id ORDER BY whateveryouwant");
?>
<tr>
<td><?php echo $parent->id; ?></td>
<td><?php echo $parent->name; ?></td>
</tr>
<?php
while($child = mysql_fetch_object($get2)) {
?>
<tr>
<td><?php echo $child->id; ?></td>
<td><?php echo $child->name; ?></td>
...
</tr>
<?php
}
?>
</table>
-Parent1
--Child
--Child
--Child
-Parent2
--Child
--Child
--Child
Hope this helpedI can always be contacted by sending a tweet @twilightws
-
23rd Dec 2010, 10:20 PM #5OPMember
This is SO much cleaner.
Reckon you could post an example for a third level? That is a "Grandchild".
-
23rd Dec 2010, 10:24 PM #6The Wise OneWebsite's:
twilight.ws ddlrank.comSure, just name how many children you want, this script is horny
PHP Code:<table>
// Head of the table like ID, name, etc goes here
<?php
$get = mysql_query("SELECT * FROM tablename WHERE parent = 0 ORDER BY whateveryouwant");
while($parent = mysql_fetch_object($get)){
$get2 = mysql_query("SELECT * FROM tablename WHERE parent = $parent->id ORDER BY whateveryouwant");
?>
<tr>
<td><?php echo $parent->id; ?></td>
<td><?php echo $parent->name; ?></td>
</tr>
<?php
while($child = mysql_fetch_object($get2)) {
$get3 = mysql_query("SELECT FROM tablename WHERE parent = $child->id ORDER BY whateveryouwant");
?>
<tr>
<td><?php echo $child->id; ?></td>
<td><?php echo $child->name; ?></td>
...
</tr>
<?php
while($grandchild = mysql_fetch_object($get3)){
?>
<tr>
<td><?php echo $grandchild->id; ?></td>
<td><?php echo $grandchild->name; ?></td>
...
</tr>
<?php } ?>
<?php
}
?>
</table>I can always be contacted by sending a tweet @twilightws
-
23rd Dec 2010, 10:35 PM #7OPMember
DOH! Why didn't I think of this
Thanks bro, you're a legend!
-
23rd Dec 2010, 10:37 PM #8The Wise OneWebsite's:
twilight.ws ddlrank.comI can always be contacted by sending a tweet @twilightws
-
24th Dec 2010, 11:48 AM #9OPMember
Saves making another thread.
The code is updated and looks as it should. http://code.google.com/p/filewire/so...s/releases.php
If the function in that class is called it should be outputting nothing as I clear the buffer at the end but save it to a variable. However, it has no effect and outputs everything: http://filewi.re/releases.php (You should be seeing a blank page)
Please tell me how this is possible
-
24th Dec 2010, 01:22 PM #10MemberWebsite's:
ExpresShare.comuse ob_get_contents() instead.
ob_get_flush outputs to the browser the saved buffer+ save it to a sting.
Sponsored Links
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Similar Threads
-
E-Mail Can Reveal Your Friend Hierarchy
By Daniel in forum News & Current EventsReplies: 0Last Post: 30th Nov 2011, 08:19 PM -
Porn Forum List "add your list"
By Mr-Egy in forum Webmaster DiscussionReplies: 3Last Post: 15th Jul 2011, 11:11 AM -
Rank Hierarchy Icons
By gmaister22 in forum Webmaster DiscussionReplies: 8Last Post: 27th Feb 2011, 06:29 PM -
List of ips what spam/ddos - Please add yours if you have a list
By Sp32 in forum Webmaster DiscussionReplies: 23Last Post: 3rd Jul 2009, 04:07 AM
themaLeecher - leech and manage...
Version 5.03 released. Open older version (or...