SunQuest
 
           MySQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesMySQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old March 19th, 2003, 04:57 AM
mylibya mylibya is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Location: Libya
Posts: 3 mylibya User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
treeview of Mysql table

Can anobody tell me how to output a treeview of MySQL table. I mean the displyed graph should look like windows explorer way of displaying directory files.

Thanx

Last edited by mylibya : March 19th, 2003 at 04:59 AM.

Reply With Quote
  #2  
Old March 20th, 2003, 01:34 PM
tylendel98 tylendel98 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2003
Posts: 5 tylendel98 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 59 m 52 sec
Reputation Power: 0
Hi,

First, go here and grab this nice javascript tree menu from this site:

www.destroydrop.com/javascripts/tree/

Then use my little example below as a guide

PHP Code:
<?php

$db_host 
"localhost";
$db_user "root";
$db_pass "";
$db_name "";

$connection mysql_connect($db_host$db_user$db_pass) or die ("Unable to connect to DB");
mysql_select_db($db_name$connection);
$query "SELECT * FROM auth_page ORDER BY pageorder";
$result mysql_query($query$connection);

?>
<div class="dtree">
<script type="text/javascript">
<!--
d = new dTree('d');
d.add(0,-1,'Example DB tree');
<?php
while ($row mysql_fetch_array($result)) {

// Node(id, pid, name, url, title, target, isopen, img)
?>
d.add(<?echo $row[id];?>,<?echo $row[parent];?>,'<?echo $row[title];?>','<?echo $row[name];?>.html');
<?php
}
?>
d.draw();
//-->
</script>
</div>


If you need some more help post here or mail me.

Regards

Tylendel

Last edited by tylendel98 : March 20th, 2003 at 01:42 PM.

Reply With Quote
  #3  
Old February 16th, 2005, 06:38 AM
angelofdarkness angelofdarkness is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2005
Posts: 1 angelofdarkness User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 m 55 sec
Reputation Power: 0
Thumbs up Great!

wow thanks alot this is exactly what i needed and its very easy to implement

Reply With Quote
  #4  
Old February 18th, 2005, 10:29 AM
tylendel98 tylendel98 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2003
Posts: 5 tylendel98 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 59 m 52 sec
Reputation Power: 0
Hi,

Glad it was of some assistance.

Regards

Tylendel

Reply With Quote
  #5  
Old February 19th, 2005, 04:56 PM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 4 m 48 sec
Reputation Power: 8
Is there a functioning example of this?
I wouldn't mind seeing what the code's output looks like.

Reply With Quote
  #6  
Old February 20th, 2005, 12:24 AM
tylendel98 tylendel98 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2003
Posts: 5 tylendel98 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 59 m 52 sec
Reputation Power: 0
Hi,

DarkMedia have been kind enought to put up a basic working example here:

http://www.dark-media.net/intel/dtree_mysql.php

Cheers

Tylendel

Reply With Quote
  #7  
Old February 21st, 2005, 08:38 AM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 4 m 48 sec
Reputation Power: 8
DarkMedia has the coolest 404 Message =)

Very cool tree code.
Thanks Tylendel

Reply With Quote
  #8  
Old February 21st, 2005, 09:28 PM
tylendel98 tylendel98 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2003
Posts: 5 tylendel98 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 59 m 52 sec
Reputation Power: 0
Hi MadCowDzz,

Your very welcome

I cannot take credit for the actual core dtree javascript only the mysql implementation!

Cheers

Tylendel

Reply With Quote
  #9  
Old September 18th, 2005, 11:54 PM
webbisnis webbisnis is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2005
Posts: 1 webbisnis User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 16 m 26 sec
Reputation Power: 0
Quote:
Originally Posted by tylendel98
Hi,

First, go here and grab this nice javascript tree menu from this site:

www.destroydrop.com/javascripts/tree/

Then use my little example below as a guide

PHP Code:
<?php

$db_host 
"localhost";
$db_user "root";
$db_pass "";
$db_name "";

$connection mysql_connect($db_host$db_user$db_pass) or die ("Unable to connect to DB");
mysql_select_db($db_name$connection);
$query "SELECT * FROM auth_page ORDER BY pageorder";
$result mysql_query($query$connection);

?>
<div class="dtree">
<script type="text/javascript">
<!--
d = new dTree('d');
d.add(0,-1,'Example DB tree');
<?php
while ($row mysql_fetch_array($result)) {

// Node(id, pid, name, url, title, target, isopen, img)
?>
d.add(<?echo $row[id];?>,<?echo $row[parent];?>,'<?echo $row[title];?>','<?echo $row[name];?>.html');
<?php
}
?>
d.draw();
//-->
</script>
</div>


If you need some more help post here or mail me.

Regards

Tylendel


can you email me all examples of your .sql, .php, .js. ?
my email : webbisnis@yahoo.com
(you know that i'm so hard to understand)

Reply With Quote
  #10  
Old September 25th, 2006, 11:05 PM
vhreporter vhreporter is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2006
Posts: 1 vhreporter User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 19 m 5 sec
Reputation Power: 0
Another attempt

Tylendel,

Thanks for your sample code. I was not able to get it to work properly and found a very similar appraoch at:

URL

I don't know what I was doing wrong using your example, but considering the post is a few years old, maybe it is a version issue of some type. Anyway, the code I used was:

Code:
<?php 
/* Begin code: */
/* My database connection include file */
require_once('../Connections/docmgr.php'); ?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html>

<head>
	<title>Document Manager</title>

	<link rel="StyleSheet" href="dtree.css" type="text/css" />
	<script type="text/javascript" src="dtree.js"></script>

</head>

<body>
<div class="dtree">

	<p><a href="javascript: d.openAll();">open all</a> | <a href="javascript: d.closeAll();">close all</a></p>

<script type="text/javascript">
<!--
d = new dTree('d');
d.add(0,-1,'Your Documents');
<?php
/* Variables from my database include file */
mysql_select_db($database_docmgr, $docmgr);
$query = "SELECT folderid, parentid, title, name FROM folders ORDER BY folderid";
$result = mysql_query($query, $docmgr) or die ("Fail Query");
while ($row = mysql_fetch_array($result)) {
extract($row);
echo("
		d.add($folderid,$parentid,'$title','test.html');
	");
}

?>
document.write(d);
//-->
</script>
</div>
</body>
</html>
<?php mysql_free_result($result); 
/* End Code */
?>

Reply With Quote
  #11  
Old April 15th, 2008, 03:42 AM
harshalone harshalone is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 1 harshalone User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 m 12 sec
Reputation Power: 0
Thanks For your Code But i have a Problem

I have coppied your code and manupulated for my local server apache with mysql

my databse looks like this

| userid | refid | name |
1001 9000 ABC
1002 1001 BTG
1003 1001 SAD
1004 1002 SDS
1005 1002 RGS
1006 1001 WER
1007 1002 WEW

And so on

I want to display all the childs acorrdingly
what should i have to change in this sctript so that it would work

Thanks in advance

Reply With Quote
  #12  
Old June 21st, 2008, 07:38 PM
SenTnel SenTnel is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2008
Posts: 1 SenTnel User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 m 37 sec
Reputation Power: 0
Treeview: very confused about data structure

Hi all!

Im migrating an MSSQL app to php / mysql and I have to deal with the way the data in MSSQL had been setup. One of the tables has only two columns: objpatid and Localizacion.

objpatid is an indexed integer identification number unique for each object in the database.

Localizacion is the column for every object, its data structured more like a "path" to a physical location in a builduing, a typical row in that column looks like this:

2ND FLOOR \ GENERAL INTENSIVE CARE UNIT \ INTENSIVE CARE UNIT ROOM ONE \ DEFIBRILLATOR

2ND FLOOR \ GENERAL INTENSIVE CARE UNIT \ INTENSIVE CARE UNIT ROOM ONE \ NEGATOSCOPE



I would like to display this in the web page as a treeview, where you have, for example, the floors, 1ST FLOOR, 2ND FLOOR, etc., then as you open 2ND FLOOR it shows the areas in second floor, let's say: GENERAL INTENSIVE CARE UNIT, etc., when you expand that area then shows ... etc.,....

The data is delimited by the " \ " (backslash).

Please, help me understand this or how can I organize this to be able to present it as a treeview.

Thanks!

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMySQL Development > treeview of Mysql table


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support |