Results 1 to 11 of 11

Thread: A little school help

  1. #1
    Join Date
    Mar 2012

    A little school help

    A have a simple task here.
    Its easy to complete but there`s some snares.
    Please give me some advice how to create it and what to drew attention.
    Thanks to everyone !

    Here is the tast with the picture inside

  2. #2
    Join Date
    Feb 2012
    Pensacola, FL
    I would use AJAX for this task, will make the page smoother. What are you stuck on, I will be better able to help.

  3. #3
    Join Date
    Mar 2012
    Its almost ready.. But i`m wondering one thing.
    How to create the menu
    When its clicked on the Root2 to show only the sub items,not everone in the db
    Should I use jquery ?! Because I really never used it

  4. #4
    Join Date
    Feb 2012
    Pensacola, FL
    Are you pulling this info from a database? And what is the PHP you are using now? (Please edit out and sensitive info). And Possibly, but I need more info before I can say yes or no. @_@

  5. #5
    Join Date
    Nov 2002
    If this is for school, then you need to find a solution based on what technologies you are suppose to know for that class. If you aren't suppose to know jQuery, then even if you get it working you won't get it right since you found an answer that doesn't line up with what it should be.

  6. #6
    Join Date
    Feb 2012
    Pensacola, FL
    Quote Originally Posted by spufi View Post
    If this is for school, then you need to find a solution based on what technologies you are suppose to know for that class. If you aren't suppose to know jQuery, then even if you get it working you won't get it right since you found an answer that doesn't line up with what it should be.
    Good point, I haven't been in school for like 6 years so I didn't think about it.

  7. #7
    Join Date
    Mar 2012


    Here I am so far:


    The function

    function menu()

    mysql_query('UPDATE sub
    SET name_sub="'.$name.'",color="'.$color.'"
    WHERE id_sub="'.$id.'" ');
    mysql_query('INSERT INTO sub (name_sub,color)
    VALUES ("'.$name.'","'.$color.'")');


    $rs=mysql_query('SELECT * FROM Main');
    echo $row['name'].'<br />';

    $rs=mysql_query('SELECT * FROM sub');
    echo '<p>';
    echo '<a href="index.php?mode=edit&id_sub='.$row['id_sub'].'" style="color:'.($row['color']).' ">'.$row['name_sub'].'</a><br />';
    echo '</p>';

    if($_GET['mode']=="edit" && $_GET['id_sub']>0)
    $rs=mysql_query('SELECT * FROM sub WHERE id_sub='.$id);

    echo '<form method="post" action="index.php">
    Title:<input type="text" name="title" value="'.$ed_info['name_sub'].'"/><br />
    Color:<select name="color">
    <input type="submit" value="submit"/>
    <input type="hidden" name="new" value="1">';

    echo '<input type="hidden" name="edit_id" value="'.$_GET['id_sub'].'">';


    I have a few questions to you.

    How can I add the new items to the Root1 Root2 Root3
    How can I list them like in the task.
    When I click Root1 to see only the items which are related to root1.

    In my DB there are 2 tables

    Table main
    id_root name color
    Auto in Root1 black
    Auto in Root2 black
    Auto in Root3 black

    Table sub
    id_sub name_sub color parent
    Auto in test magenta 0
    Auto in dobre blue 0
    Auto in welcome! green 0

    I need to make them connected to the parent:root1,2,3 or themself

    I really dont think I need 2 tables,right ?!

  8. #8
    Join Date
    Feb 2012
    Pensacola, FL
    Do do the trees properly, without Javascript/jQuery, you are going to want to use the GET method to get the sub cats. For example:
    PHP Code:
    $rootid $_GET['root'];
    $tree mysql_query("SELECT * FROM $db.$table WHERE sub_id = '$rootid'");
    $sub '';
    $fulltree mysql_fetch_array($tree)){
    $sub .= '<a href="?root='.$rootid.'&sub='.$fulltree['id'].'">'.$fulltree['name'].'</a>';
    Try seeing if you can modify that to fit your needs. I would write it for you but then you will never learn. XD

  9. #9
    Join Date
    Nov 2002
    If I understand this correctly...
    Table root
        id, name, color
    Table submenu
        id, rootid, name, color.
    1. Select for each root item.
    2. Loop through the resulting array.
        a. Display each root item.
        b. Select from submenu where root.id = rootid.
        c. Loop through resulting array
            i. Display each submenu item.

  10. #10
    Join Date
    Mar 2012
    I was in a mistake.
    There is no root...
    I need only one table.
    It should look like this:

    --Item3(child of Item2)
    --Item5(child of Item4)
    --Item6(child of Item4)
    ----Item7(child of Item6)
    ----Item8(child of Item6)
    ------Item9(child of Item8)

    and so on....

    There`s no problem to write the parent ID in the DB when create new item.
    The question is how to draw the tree.
    Should I use a recursion?
    I must start the recursion and calling it every time when there is some deeper Item on the tree.
    I can`t figure it out how it should be made

  11. #11
    Join Date
    Aug 2004
    Some reading material for the weekend, after which you can decide which technique is right for this implementation: http://mikehillyer.com/articles/mana...data-in-mysql/
    "Well done....Consciousness to sarcasm in five seconds!" ~ Terry Pratchett, Night Watch

    How to Ask Questions the Smart Way (not affiliated with this site, but well worth reading)

    My Blog
    cwrBlog: simple, no-database PHP blogging framework

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center



X vBulletin 4.2.2 Debug Information

  • Page Generation 0.44377 seconds
  • Memory Usage 2,959KB
  • Queries Executed 15 (?)
More Information
Template Usage (35):
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_global_above_footer
  • (1)ad_global_below_navbar
  • (1)ad_global_header1
  • (1)ad_global_header2
  • (1)ad_navbar_below
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)ad_thread_first_post_content
  • (1)ad_thread_last_post_content
  • (1)bbcode_code
  • (1)bbcode_php
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)headinclude_bottom
  • (11)memberaction_dropdown
  • (1)navbar
  • (4)navbar_link
  • (1)navbar_moderation
  • (1)navbar_noticebit
  • (1)navbar_tabs
  • (2)option
  • (11)postbit
  • (11)postbit_onlinestatus
  • (11)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available (6):
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files (26):
  • ./showthread.php
  • ./global.php
  • ./includes/class_bootstrap.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/functions_navigation.php
  • ./includes/class_friendly_url.php
  • ./includes/class_hook.php
  • ./includes/class_bootstrap_framework.php
  • ./vb/vb.php
  • ./vb/phrase.php
  • ./includes/functions_facebook.php
  • ./includes/functions_calendar.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_notice.php
  • ./packages/vbattach/attach.php
  • ./vb/types.php
  • ./vb/cache.php
  • ./vb/cache/db.php
  • ./vb/cache/observer/db.php
  • ./vb/cache/observer.php 

Hooks Called (70):
  • init_startup
  • friendlyurl_resolve_class
  • init_startup_session_setup_start
  • database_pre_fetch_array
  • database_post_fetch_array
  • init_startup_session_setup_complete
  • global_bootstrap_init_start
  • global_bootstrap_init_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • load_show_variables
  • load_forum_show_variables
  • global_state_check
  • global_bootstrap_complete
  • global_start
  • style_fetch
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • strip_bbcode
  • friendlyurl_clean_fragment
  • friendlyurl_geturl
  • forumjump
  • cache_templates
  • cache_templates_process
  • template_register_var
  • template_render_output
  • fetch_template_start
  • fetch_template_complete
  • parse_templates
  • fetch_musername
  • notices_check_start
  • notices_noticebit
  • process_templates_complete
  • friendlyurl_redirect_canonical
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • memberaction_dropdown
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • build_navigation_data
  • build_navigation_array
  • check_navigation_permission
  • process_navigation_links_start
  • process_navigation_links_complete
  • set_navigation_menu_element
  • build_navigation_menudata
  • build_navigation_listdata
  • build_navigation_list
  • set_navigation_tab_main
  • set_navigation_tab_fallback
  • navigation_tab_complete
  • fb_like_button
  • showthread_complete
  • page_templates