[php+mysql] best way to integrate a tree category menu base on db?

Hi all,
I have a products catalog where all products are organized in
categories.
The category structure is something similar to this:
category 1
subcategory 1.1
sub-subcategory 1.1.1
sub-subcategory 1.1.2
sub-subcategory 1.1.3
sub-subcategory 1.1.4
sub-subcategory 1.1.5
subcategory 1.2
subcategory 1.3
category 2
subcategory 2.1
subcategory 2.2
sub-subcategory 2.2.1
sub-subcategory 2.2.2
sub-subcategory 2.2.3
sub-subcategory 2.2.4
subcategory 2.3
...and so on...
In general, I have 3 category levels.
I manage these catagories with only one table using self
foreign keys.
Now I need to add a tree menu that will reflect the above
category
structure.
I use php + mysql to store the tables (products and
categories.
I found several javascript samples that allow you to do
something similar
but with static data.
I'm searching for a tree menu that is easily customizable and
that can use
dynamic data from mysql db.
Is there a tutorial or smple that would do the trick?
TIA very much!
tony ;).

The page I'm trying to create is here www.hollisterairshow.com/plan-results.php and the questionnaire is here www.hollisterairshow.com/helpusplan.php .
I went ahead and created recordsets using advanced recordsets and these seem to be working, here's a sample SQL
SELECT *
FROM plan
WHERE Saturday = 'Saturday' AND plan.howArriving = 'Auto'
I created a recordset for each combination of day and transportation mode - six in all
This selected the correct records.
To display the count of how many records selected I then used in DW Insert/Data Objects/ Display Record Count/Total Records which generated the following code:
<?php echo $totalRows_rsSatAuto ?>
This worked OK - not elegant but OK and I repeated it for each combination of Day and Transportation mode!!
So there are two problems I'm having:
I know I can select the records I want but how do I display the sum of the column containing "How many in your party" - i.e. in the PHP code generated above what do I replace $totalRows_rsSatAuto with?
There are two questions using radio buttons where I'd like to display the count and % for each option selected. I can select all records for these questions but what code do I put to sum the number of selections for each option and what code do I put to calculate the percentage
I understand the arithmetic involved which is pretty simple but it's the mechanics of coding that has me stumped. It would really help if you could give me a sample for say the "Are you camping overnight" question which has a "Yes/No" option only. In my mundane way I would create two recordsets, one for "Yes" and one for "No", and use the same technique I describe above for counting Total Records in each recordset, but then I'm stuck with how do I calculate and display the percentages. I must be missing something very obvious as I'm sure there just has to be a more elegant solution.
Thanks so much for your continued interest.
Tony

Similar Messages

  • Best way to Display a tree in Adobe Forms i.e. Classification

    As I am new to Adobe interactive and do not have the experience that many of you have, I am posting a general question in that what is the best way to display a tree like structure of data in Adobe Forms so that a user can select a 'leaf' node easily. 
    I have looked at and coded drop downs that drive the data in the next drop down and it seems to work but it is not pretty and is a lot of work to handle the requirements for different levels of data.  we have suggested that they select the Classification in a Webdynpro pop-up before they go into the form meaning that the classification will only work when  they are on line.  I looked briefly at using imbeded tables but they would be too big(should I look at them further?)....   There could be upwards to 3000 rows in the classification table.
    Example of data
    Level 1
    === level 11
    === level 12
    Level 2
    === Level 21
    Level 3
    === Level 31
    ====== Level 311
    ====== Level 312
    Thanks in advance for any ideas and learnings you may have.
    Glenn

    After talking to a number of people, I have determined the best way is to use dynamic dropdown lists to show the hierarchy.
    Glenn

  • Best way to make a tree?

    i'm fairly new to java and I want to do a program involving binary trees but I'm trying to figure out the best way to get a tree to start with. I'm not really sure of the best way.
    Also, after running the program I want to be able to add to and edit the tree and then be able to output to a file so that the tree grows when ever i want to use it.
    basically im trying to do a 20 questions program that guesses what you're thinking of by asking questions (in the tree) and then if its something not in the tree it can add it to the tree (and whatever questions necessary)

    this is basically what I've done
    to build it i started with
    TreeNode root=new TreeNode("Is it living?",new TreeNode("Is it an animal?",null,null), new TreeNode("Is it an object?",null,null));
    [so basically I have a node asking if its alive and then if it is alive it goes to the left with a node askin if its an animal or if not, to the right asking if its an object. so thats my tree and I have code to insert etc. But now I want to have this tree put in a file so that it can be saved and then built back into a tree so in reality i guessI wouldn't have that code anyway, just code to load a tree from a file. how do i do that?

  • What is the best way of integrate a jsp aplication created in jdev 3.2.3 with portal

    Hi,
    I've a jsp aplication made in jdeveloper 3.2.3 and i need to integrate this application into portal. What is the best way of doing this?
    thanks in advanced
    ricardo

    Hi,
    I've a jsp aplication made in jdeveloper 3.2.3 and i need to integrate this application into portal. What is the best way of doing this?
    thanks in advanced
    ricardo

  • Best way to integrate digital media to home AV system?

    What is the best way that folks like these days to integrate digital media into a traditional AV system?
    Let's say one has a home theater A/V reciever, dvd player, record player, HD TV and surround sound. What is the best device or devices to add on to this to access a digital music and video library?  Also what is the best way to share that library throughout the house so that it can be accessed by multiple people at one time?

    Hello, I see your question has been out there for a while.  But I just went through this myself and would recommend the new 3rd Generation Apple TV for just this purpose.  I see this is listed under an iTunes for Windows discussion group, so you may not be using Apple systems for your home computer.  However, I recently purchase a home computer system with one of the main goals being to access high resolution audio files from my iTunes library and play them over our home stereo system.  Using Apple's Home Sharing and their Apple TV device you can access high quality audio and video files on your home network and enjoy them over your HD TV and home stero system.  You can also access these files through other devices (smart phones, tablets and laptops).  I don't have any knowledge of how well the system works with non-Apple devices, but we have enjoyed it with our Apple system.
    The link below may also be helpful.
    https://discussions.apple.com/message/24297469#24297469

  • What is the best way to organize a tree-like structure of constants?

    Hello everone!
    Need help with organizing my constants structrure.
    I have several tables, and each of them need a list of column names to define the fields returned after query, and also a corresponding list of hashmap keys because that columnnames are ugly. Hashmap is where I store the result of searching through the table. This question is not about JDBC because I search through tables via COM interface, no JDBC ResultSets and other stuff here.
    Finally, for each table I have two constant lists and I have a list of tables. What is the best way to store this?
    My first idea was to create a enum and store column data in it as String array attributes: String[] columnNames; etc.
    But in this case I cannot use each column and key separately.
    Another option is to create two separate enums for each table: columnNames enum and keys enum. That doesn't look great also.
    The third option is to create inner class for each table and store two enums in each of that classes.
    Also I can store all data in hashmaps, Strings etc.
    (1) Finally, from your experience, what is the best way to organize all that stuff?
    (2) I have heard that smart Java programmer should avoid using the enums by any means. Do you agree?
    (3) Generally what will you prefer when creating a constant which has two values: two final Integers or enum?
    Edited by: Dmitry_MSK on Jul 8, 2010 5:22 AM

    I'm not sure why you don't just invent a generic data structure (e.g., table name, list of column names and aliases of column names) such as:
    class QueryMetaData {
      private final String tableName;
      private final String[] columnNames;
      private final String[] columnAliases;
    }Read into the above structure from a properties file, database table, etc. You can store meta-data itself in places other than enum constants, particularly if would like to change the meta-data without requiring a new build of your application.
    That having been said, WRT to your specific questions:
    (1) Finally, from your experience, what is the best way to organize all that stuff?See above
    (2) I have heard that smart Java programmer should avoid using the enums by any means. Do you agree?Enums are better than simple constants using int or String or something similar. If there are known, discrete values unlikely to change frequently, I see no issues with an enum. They improve the readability of code, and there are enough syntactic sugar features in the language (switch statements come to mind) to make them appealing.
    (3) Generally what will you prefer when creating a constant which has two values: two final Integers or enum?
    See above. Enums were introduced (in large part) to do away with storing constants as integers.
    - Saish

  • Best way to integrate all services

    TO ALL:
    Please Help me figure this mess out.
    We use the following services for our business
    Windows InTune
    Office 365
    SQL Azure
    Dynamic CRM Online
    I would like to (hopefully) combine all administration functions and portals of these sites.  Although I am running dated Server OS's (mostly server 2003 R2) I am hoping to upgrade to 2012 this calendar year.  That is why I have not looked into
    all the AD sync services at this time. 
    Hopefully someone has gone through this - and can advise the best way to merge all the information together.

    Yes, I know this is an old post, but I’m trying to clean them up. Did you solve this problem, if so what was the solution?
    Garth Jones | My blogs: Enhansoft and
    Old Blog site | Twitter:
    @GarthMJ

  • What is the best way to integrate a sound file (mp3) into a PDF?

    I saw that its possible to do it by Tools->Multimedia->Sound. This works fine on a computer but not a tablet. So what is the right way to embed a sound file into a PDF of maybe by Indesign? What i want is that people can easily open a document (PDF) on a tablet and when they click on a (play)icon that they hear a sound file. The best thing is that they can stop or put it on pause.

    I think this functionality relies on Flash, so it's not likely it's going
    to work on mobile devices, certainly not on iOS ones.

  • What is the best way to integrate an ER diagram into BPA?

    Hi,
    In the context of a conversion project, trying to understand what is the lighter and easier way to import an ER diagram into BPA. The tools I'm currently using allow me to generate any xml/text data from current models... but trying to understand the minimal effort so the main semantic of models get kept (not a big deal if fonts, positioning, layout things are lost on the way)
    Attached is an example problem, would be great to see what textual representation denoting the same semantic can be accepted by BPA
    My example model:
    Product(prod_id (pk), name) ---* Order({prod_id, cust_id} (pk), quantity_ordered) * --- Customer (cust_id (pk), cust_name)
    A customer can have 0 to many orders
    A product can be ordered by 0 to many customers
    A order is made for 1 product and 1 customer, and for each order we know the quantity of the product ordered
    if someone has already run integration of large ERds into BPA would be fantastic help to have some hints/feedbacks on your approach best practices
    kind regards
    Frederic

    There is a thrid party product that con convert data models between most tools, including BPA. You can find information about it here: http://www.reischmann.com/. If you just want to migrate the main objects and their characteristics and the diagram is not as important you could look at using Excel as a data transfer medium. The report "Import Data in Excel Format" allows you bring information into BPA quickly, however it is a one time conversion and won't accomodate updates. You could also look at the macro "Process Generator" which also allows for objects to be imported from an Excel SS. Either of the SS solutions will require some configuration.

  • What's the best way to integrate third party shopping carts with ATG's (10.6)?

    Hi,
    We are using ATG (10.6) for our e-commerce platform and we have many other websites which try to engage the end user to buy our products.
    Those other websites are developed using different technologies but we would like to allow the visitor to click a buy button and add things to a local shopping cart. That "generic" Shopping cart will be hosted locally in the website and only when he/she tries to "check out" we will forward them to e-commerce (ATG) main page, but the ATG's shopping cart has to have all the item he/she selected previously on the website.
    How can that be done?
    1) In the best possible way?
    2) In the simplest possible way?
    Regards

    Hi,
    We have seen that. Thanks.
    Now, how could we add multiple tiems to ATG's shopping cart before redirecting the user to ATG's home?
    The scenario we see is:
    User navigates on a Marketing website, spots items he/she is interested in and add them to the LOCAL shopping cart (without leaving the current website), after adding many items he/she decides to buy these items buy clicking FINISH, at this moment we add the N items to ATG shopping cart (how??) and redirect the user to ATG's home.
    Is that possible?
    Thanks

  • Flex, PHP, MySQL Best Practices?

    When using the HTTPService to invoke PHP/ database
    transactions what are some best practices to insure multiple
    simultaneous users successfully complete the transaction?
    So, in my Actionscript I build an object to pass to the PHP
    script that uses the values of the object to build a SQL query and
    executes the query, evaluating the result.
    Right now, I'm returning a text string from the PHP script
    (after error checking there) that simply says "ok" if the script
    succeeded.. and using that string in the HTTPService.Result
    (lastResult) listener.
    Anyone have any experiences to comment on?
    thanks,
    Dan

    Or use AMFPHP and pass typed objects back and forth. I find
    this much easier than working with XML. Once you've used AMFPHP on
    one project, you'll wonder why you bothered with XML. Or at least
    that's how it was for me. AMFPHP 2.0 should be released very soon -
    I believe they're just getting the docs ready.
    Cheers,
    Darren.

  • Best way to create XML tree --- Swing??

    My program reads form an XML file upon launching to get all the ground data and the file structure and all that good stuff so it can simulate what it simulates (doesn't matter and I can say anyway).
    It's getting to be a PITA to maintain and add stuff to my XML config file. So, what's the bast way to build XML files through a GUI like swing. Hmmmmmmm.
    Sorry for the vague question.
    I was thinking building something like elplorer with pop up windows and buttons to add elemts into the XML, but so the elements would always be added into the correct position.

    Hi,
    use javax.swing.JTree
    http://galileo.spaceports.com/~ibidris/

  • Best way to integrate Blog into Website?

    Having gotten past the CSS hurdle, my next project is to build a complete custom designed site with an integrated blog. I have looked at options taking this from the other direction, such as customizing Wordpress to the extent that it functions as both site and blog. I've also looked at Joomla. But these solutions I feel are going to present more problems when I want to add additional CMS, shopping cart and other things.
    Another solution would be to create the site, then install Wordpress into a subfolder where the Blog link on the main nav mane would link to that. This would be OK, except now I'd be running into customization issues with the Blog UI as well as navigation back to the main site. It would still have that feeling of disconnect, being essentially two separate applications.
    Ideally, I'd like to have the Blog just be it's own page, or subfolder within the main site - but rather than just providing a feed to that page, be able to retain all the features of the blog including the admin section of Wordpress as well as RSS syndication. Podcasts may enter into the picture as well.
    Does anyone have any ideas on this from either experience or brainstorming?  Any input appreciated!

    To first answer the above question, it took me about a month to "learn" CSS. But that doesn't mean that I could create a site from scratch as I am a subscriber to WebAssist's extensions library. So I cheated. While it does the heavy lifting, I still needed to acquire enough knowledge along the way to be able to modify and customize - and not just in a hacking sort of way, but actually grasping what is going on with the code.
    These are very valuable tools, but not without their drawbacks.  For example, I'm not sure if I'm fully prepared to take on other projects based on CSS, say, Wordpress themes!  I'm sure I cojuld - that I know have the necessary foundation, but I'm looking at another learning curve of indeterminate length.
    So, yes, I can see where going to WP route may be the overall better solution in the long run. Outside of customizing the UI, there are many other things I can't seem to get my head around, as stated above. But if I were to go in that direction, would it also be worth it to look at Joomla?
    And if I decided to stick with my original solution, at least for this project, is there a fairly easy way to do it? Basically, all I'd want for the Blog page or section is just the content of the blog - the articles, archives, tags, comments.  No navigation, etc. I do realize that with this I would have two CMS interfaces - one for the site and one for the blog, but that would be OK.
    Thanks for your input!

  • Best way to integrate osx server with ms server 2004

    I want to be able to manage files & users from either server, the OSX server & Windows Server 2003. What's the best road map & best practices. It's a small network of 5 computers in total. Thanks for all the help. Ben

    first of all, to get rid of the duplicates, you tell iTunes to consolidate Library.
    I think you may be missing the idea of what iTunes does for you. If you have content, like music, that you want to find the file of, you right click the name of the file in itunes and then "show in finder" . For things like iChat, you can simply drag and drop your music into the chat window from itunes, just like it was finder. iTunes organizes your media for you so you don't have to go looking for it.
    The same thing goes with videos.
    There is no reason to have two of the same files on your computer. Think of iTunes like finder, only it plays media too.
    Not everyone uses itunes. Things like quicktime player, after you do a recording, will save the content into your videos folder. They're not on itunes but it uses your video folder to save the recordings. This is just one example of how your video sidebar icon folder will still be useful.
    Delete the backups you have of your media unless they're in a format the itunes doesn't support, like lossess formats such as Flac, because it is pointless and wasteful to have two of the same files for music and video on your computer.

  • Best way to integrate system Music & Movies folders with iTunes' default folder structure?

    I understand that OSX has system folders that can't be moved (Music, Movies, Documents, etc.).  These folders are the only ones that get their specialized icons in the sidebar.  I like those icons as they make choosing the right folder easier (even though I can read).
    MUSIC:
    Isn't there something very un-elegant to have my actual music files buried 4 layers deep in OSX's folder structure?  By that I mean, I'd like to click on my (system) Music folder and see my music.  But OSX and iTunes have schemed to make users have to deal with  Music/iTunes/iTunes Media/Music.  It's weird, right?
    I am aware that the iTunes library location can be altered via Advanced Prefs, but I like having Music, Podcasts, Movies, etc. be on the same folder level, if that makes sense.  If I point iTunes to my (system) Music folder, then my other media will be down below in the iTunes Media folder.
    MOVIES:
    Likewise, if I let iTunes manage my files, movies go to the Music/iTunes/iTunes Media/Movies folder.  I don't let iTunes copy everything into the Media folder (as I don't want to eat HD space with duplicates), but that's still where it wants movies to go when it organizes.  Similar to the Music folder issue above, how can I make use of my (system) Movies folder given this setup?
    I know that I can just remove whatever folders I want from the sidebar and put in the ones that iTunes uses, but then I lose out on the icons and I end up having permanent folders in my Home folder that don't even get directly used for the media files they're supposed to hold.
    Thoughts?

    first of all, to get rid of the duplicates, you tell iTunes to consolidate Library.
    I think you may be missing the idea of what iTunes does for you. If you have content, like music, that you want to find the file of, you right click the name of the file in itunes and then "show in finder" . For things like iChat, you can simply drag and drop your music into the chat window from itunes, just like it was finder. iTunes organizes your media for you so you don't have to go looking for it.
    The same thing goes with videos.
    There is no reason to have two of the same files on your computer. Think of iTunes like finder, only it plays media too.
    Not everyone uses itunes. Things like quicktime player, after you do a recording, will save the content into your videos folder. They're not on itunes but it uses your video folder to save the recordings. This is just one example of how your video sidebar icon folder will still be useful.
    Delete the backups you have of your media unless they're in a format the itunes doesn't support, like lossess formats such as Flac, because it is pointless and wasteful to have two of the same files for music and video on your computer.

Maybe you are looking for