1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

PHP Scripts for treeview for database record

Discussion in 'PHP & Perl' started by gbherson, Jul 28, 2008.

  1. gbherson

    gbherson Jr. VIP Jr. VIP Premium Member

    Joined:
    Nov 29, 2007
    Messages:
    174
    Likes Received:
    967
    Hi all,

    Can somebody share with me how to make PHP Scripts for tree viewing database record?

    I'll really appreciate it.

    Thanks in advance!
     
  2. drdankmendez

    drdankmendez Junior Member

    Joined:
    May 30, 2008
    Messages:
    194
    Likes Received:
    316
    Location:
    In front of my computer
    Well, I'm not entirely sure what you are asking for but I am assuming you are trying to make a dynamically populated tree with the data from your SQL database...

    Kinda like:

    Root Item
    |_SubItem


    If this is what you are trying to do then there are a bunch of different things to consider. But before I go further, I would like to say that if you do not have solid PHP and mySQL (at least) background then you will probably be better off heading over to one of the freelance boards such as eLance or GetACoder and hire someone to do this for you.

    Now onto the considerations....

    First, how is your database structured? I am assuming the structure hierarchy is setup correct for Parent/Child relation ships between tables. The structure of your database is going to be one of the biggest things to consider BEFORE you start coding.

    The second thing that needs to be thought about is what the tree will need to do. Does it just need to display the data in tree format with all nodes expanded, or does it need the ability to expand/close the branches of the trees? Do you need to be able to click on the particular tree items and have another function occur? Will you be adding items to the database from the tree to the database and having the tree refresh. Will color coding need to be done.

    If you just need a basic tree displayed that shows all data in parent/child relationships then this can be done purely with PHP and mySQL (and of course html).

    If you need the ability to expand/close branches you will need to implement javascript and use php to create XML to be imported by the javascript.

    If you want to be able to add items dynamically to the database and refresh the tree you will need to use a technology like AJAX.

    I cannot really get into examples of code or exact methodology without knowing first how your database is setup and what the overall goal of this tree is.

    I hope I have understood what you were asking, and that I have given you some things to consider that will help you with your development.

    I would be happy to help you more with this if you need it, I will just need some more information. Just let me know.
     
  3. bwh48

    bwh48 BANNED BANNED

    Joined:
    Jun 30, 2007
    Messages:
    56
    Likes Received:
    54
    Try checking out some sites like:

    http://www.dynamicdrive.com

    I am sure they have something like this..

    Hope this helps