setting a value for index.php page -


is there way set value index.php page on first load?

i index.php load "index.php?subject=1" when loads first time. value change move around in site don't want fixed value.

some 1 sugested

 if(empty($_session['visited'])) {     //do stuff      $_session['visited'] = true; } 

i cant seem work function.

find_selected_page()

function find_selected_page () {     global $current_subject;     global $current_page;     if (isset($_get["subject"])) {     $current_subject = find_subject_by_id ($_get["subject"]);     $current_page = find_default_post($current_subject ["id"]); } elseif (isset($_get["page"])) {     $current_subject = null;     $current_page = find_page_by_id ($_get["page"]);  } else {     $current_page = null;     $current_subject = null; } } 

index.php

<?php     require_once($_server['document_root'].'/session/session.php');     require_once($_server['document_root'].'/db/dbcon.php');     require_once($_server['document_root'].'/inc/functions.php');     $context = "public";     find_selected_page (); ?> <html>   <head>     <title>home</title>    <?php   include($_server['document_root'].'/inc/style.php'); ?> <body> <?php   include($_server['document_root'].'/inc/header.php'); ?> <?php   include($_server['document_root'].'/inc/nav_ribbon.php');?>     <div id="p2dbg">         <div id="p2dcontent">             <div class="p2dcontent">         <h1><?php echo htmlentities($current_subject ["menu_name"]); ?></h1><br />                 <?php if ($current_page) { ?>                         <p><?php echo nl2br($current_page ["content"]); ?></p><br />                         <?php } else { ?>                             page not exist! please slect page menu.                         <?php } ?>                                   </div>         </div> <?php   include($_server['document_root'].'/inc/footer.php'); ?>     </div> </body> </html> 

instead of setting null if value isn't passed, assume default value:

// set value want default define("defaultsubject",1); function find_selected_page () {     global $current_subject;     global $current_page;     if (isset($_get["subject"])) {         $current_subject = find_subject_by_id ($_get["subject"]);         $current_page = find_default_post($current_subject ["id"]);     } elseif (isset($_get["page"])) {         $current_subject = null;         $current_page = find_page_by_id ($_get["page"]);      } else {         $current_subject = find_subject_by_id (defaultsubject);         $current_page = find_default_post($current_subject ["id"]);     } } 

Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -