Crossing PHP and Javascript

Discussion in 'PHP' started by XhennerzX, Aug 26, 2008.

  1. #1
    Hello!!!

    What im trying to do now is have an information bar on my website which is just a javascript bar at the top of the webpage which stays there and users have the choice to close it. Anyway... on this bar I want there to be a member menu...e.g: login, register...etc and if logged in... My profile...etc.

    Anyway I have the scripts for the Menu in PHP... and Javascript bar, but I need them to be combined together to make this happen, so that the menu is on to the bar.

    This is the menu script=


    <?php

    //Ouput pages
    if($is_logged == true){
    $page_list = array('My Profile','Logout','TOS','Privacy Policy','Site Stat','Contact Us');
    if($array_info[3][0] == '1'){
    $page_list = array('My Profile','Send Invite','Logout','TOS','Privacy Policy','Site Stat','Contact Us');
    } else {
    $page_list = array('My Profile','Logout','TOS','Privacy Policy','Site Stat','Contact Us');
    }
    } else {
    $page_list = array('Register','Login','TOS','Privacy Policy','Site Stat','Contact Us');
    }

    foreach($page_list as $page){
    $bads = array('<!--','-->');
    $page_link = strtolower(str_replace(' ','_',$page));
    echo str_replace($bads,'',$array_info[1][0]);
    if($_GET['page'] == $page_link){
    echo $page;
    } else {
    echo '<a href="?page='.$page_link.'">'.$page.'</a><br>';
    }
    echo str_replace($bads,'',$array_info[2][0]);
    }

    ?>




    and the javascript top bar is=





    <script type="text/javascript">
    <!--Invocation code-->

    var infobar=new informationbar()
    infobar.setContent('<a href="index.php?page=login_">Login</a> <a href="index.php?page=register_">Register</a>')
    //infobar.setfrequency('session') //Uncomment this line to set information bar to only display once per browser session!
    infobar.initialize()

    </script>
    </head>




    could someone please help me put them together so that the links are on the top bar?

    Thanks

    Henry!
     
    XhennerzX, Aug 26, 2008 IP
  2. grandpa

    grandpa Active Member

    Messages:
    185
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    75
    #2
    
    <script type="text/javascript">
    <!--Invocation code-->
    var infobar=new informationbar()
    infobar.setContent('<?php
    //Ouput pages
    if($is_logged == true){
    $page_list = array('My Profile','Logout','TOS','Privacy Policy','Site Stat','Contact Us');
    if($array_info[3][0] == '1'){
    $page_list = array('My Profile','Send Invite','Logout','TOS','Privacy Policy','Site Stat','Contact Us');
    } else {
    $page_list = array('My Profile','Logout','TOS','Privacy Policy','Site Stat','Contact Us');
    }
    } else {
    $page_list = array('Register','Login','TOS','Privacy Policy','Site Stat','Contact Us');
    }
    
    foreach($page_list as $page){
    $bads = array('<!--','-->');
    $page_link = strtolower(str_replace(' ','_',$page));
    echo str_replace($bads,'',$array_info[1][0]);
    if($_GET['page'] == $page_link){
    echo $page;
    } else {
    echo '<a href="?page='.$page_link.'">'.$page.'</a><br>';
    }
    echo str_replace($bads,'',$array_info[2][0]);
    }
    ?>')
    //infobar.setfrequency('session') //Uncomment this line to set information bar to only display once per browser session!
    infobar.initialize()
    </script>
    
    Code (markup):
     
    grandpa, Aug 26, 2008 IP