Results 1 to 5 of 5

Thread: Simple php/html help please

  1. #1
    Join Date
    Nov 2012

    Question Simple php/html help please

    Hi there, I'm new to the IT industry. I will finish my bachelor's degree in a few weeks. I would like a little help on a small part of functionality I wish to include in my final project.

    Basically I would like to send across a variable in the browser and retrieve it using the $_get function. I want to add a #name anchor to the end of the address so when the page loads, it loads to the bottom of the page whilst retrieving the relevant content that applies to the variable being sent through the address bar.
    My code is similar to this structure:

    $leftimg = '<a href="galleries.php?left='.$cl.'#imagenav"> <img src="../images/scrollleft.png" class="imgleft" alt=""/> </a>';
    $rightimg = '<a href="galleries.php?right='.$cr.'#imagenav"> <img src="../images/scrollright.png" class="imgright" alt=""/> </a>';
    <div id="imagenav"></div>
    echo $leftimg;
    echo $rightimg;

    So when page loads It should go to bottom whilst passing the variable to that page. It works... kind of, I can get the variable fine and it loads dynamically and accordingly to the variable sent by retrieving it using the $_get function. But does not go to where "imagenav" is located.

    I tried this by manually setting the variable $cr or $cl to a static value, the same thing happened, however when I clicked it a second time, the page focused to the bottom of the screen where "imagenav" is located (obviously the page content remained the same the second time around it was clicked).

    Any help is appreciated. Also i'm new here, so if in wrong forum please redirect me.

  2. #2
    Join Date
    Aug 2012
    I am not quite sure I have fully understood what you are trying to do but it appears that you are trying to pass a variable/value using $_GET and use it to trigger the anchor point (and presuming $imagenav = $_GET['imagenav'], in which case:
    $leftimg = '<a href="galleries.php?left='.$cl.'#'.$imagenav">';

  3. #3
    Join Date
    Nov 2012
    I think its simpler than what your trying to suggest!

    imagenav is not a variable. It is the ID of the div specified, so when the link is clicked and page has loaded, it loads and focuses to where <div id="imagenav"></div> is located.

    E.g. when clicking the link, it may look like this:

    Note: The variable/value is used to get an ID and use that to display an image/description using $_get. (Which works fine.)
    -> Then... to anchor point to the DIV named "imagenav"

    I hope that makes sense? In otherwords, Can I combine a $_get variable with a #anchorpoint in the one link? and how do I do that?

  4. #4
    Join Date
    Aug 2012
    Sorry, I missed the div (it was late at night ). However, you can't focus a link on a div, you have to use an anchor point so you would need to change the div to an anchor point or add in the anchor point by/within the div, for example
    <div id="imagenav"><a name="imagenav"></a></div>
    // OR just
    <a name="imagenav"></a>
    Then your link code should work as I can't see anything wrong with that.

  5. #5
    Join Date
    Nov 2012
    <a> tag or <div> tag its still behaving the same for me. Like I said, The variable changes and the page loads new content each time the user clicks that left or right button. The browser seems to be ignoring the Anchor point because of this somehow... If this variable doesn't change and I set it to a specific value, the second time around it is clicked, it works... I'm not sure, Maybe I'm loading the page twice or something... Thanks for help but its probably something wrong with how the rest of my code is executing.

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.09142 seconds
  • Memory Usage 2,882KB
  • Queries Executed 15 (?)
More Information
Template Usage (33):
  • (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
  • (2)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)headinclude_bottom
  • (5)memberaction_dropdown
  • (1)navbar
  • (4)navbar_link
  • (1)navbar_moderation
  • (1)navbar_noticebit
  • (1)navbar_tabs
  • (2)option
  • (5)postbit
  • (5)postbit_onlinestatus
  • (5)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 (72):
  • 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_postinfo_query
  • fetch_postinfo
  • 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