Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8073087
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T14:13:29+00:00 2026-06-05T14:13:29+00:00

Are PHP scripts reads from top to bottom? like HTML? because in this code

  • 0

Are PHP scripts reads from top to bottom? like HTML? because in this code

<?php require_once("./includes/connection.php")?>
<?php require_once("./includes/functions.inc.php"); ?>
<?php 

    if(isset($_GET['subj']))
    {
        $sel_subj = get_subject_by_id($_GET['subj']);
        $sel_page = NULL;

    }else if(isset($_GET['page']))
    {
        $sel_subj = NULL;
        $sel_page = get_page_by_id($_GET['page']);
    }else
    {
        $sel_subj = NULL;
        $sel_page = NULL;
    }


?>
<?php include("includes/header.inc.php"); ?>
<table id="structure">
    <tr>
        <td id="navigation">
            <ul class = "subjects">
                <?php

                    $subject_set = get_all_subjects();

                    while($subject = mysql_fetch_array($subject_set))
                    {
                        echo "<li";
                        if($subject['id'] == $sel_subj['id']) {echo " class =\"selected\"";}
                        echo "><a href=\"content.php?subj=" . urlencode($subject["id"]) . 
                        "\">{$subject["menu_name"]}</a></li>";

                        echo "<ul class = 'pages'>";

                        $page_set = get_pages_for_subject($subject['id']);

                        while($page = mysql_fetch_array($page_set))
                        {
                            echo "<li"; 
                            if($page['id'] == $sel_page['id']){echo " class = \"selected\"";}
                            echo"><a href=\"content.php?page=" . urlencode($page["id"]) .
                            "\">{$page["menu_name"]}</a></li>";
                        }
                        echo "</ul>";
                    }
                ?>
                </ul>
        </td>
        <td id="page">
                <?php if(isset($sel_subj)){?>
                    <h2><?php echo "{$sel_subj['menu_name']}";?></h2>
                <?php } ?>  
                <?php if(isset($sel_page)){?>
                    <h2><?php echo "{$sel_page['menu_name']}"?> </h2>
                <?php }?>
        </td>
    </tr>
</table>
<?php require("includes/footer.inc.php"); ?>

specifically this part

if(isset($_GET['subj']))
        {
            $sel_subj = get_subject_by_id($_GET['subj']);
            $sel_page = NULL;

        }else if(isset($_GET['page']))
        {
            $sel_subj = NULL;
            $sel_page = get_page_by_id($_GET['page']);
        }else
        {
            $sel_subj = NULL;
            $sel_page = NULL;
        }

How is this if-else block being called if it’s on top of the page?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T14:13:32+00:00Added an answer on June 5, 2026 at 2:13 pm

    It is run top-to-bottom one time per page view. On the initial view, assuming the URL has no parameters, then neither $_GET['subj'] or $_GET['page'] will be set.

    If the link pointing back to the same page is clicked, then the entire PHP file will be reprocessed. If that link contained subj or page in the URL as a query variable, then the corresponding if block will be executed and the page will be altered accordingly.

    Think of the PHP server as dynamically creating some HTML file that is sent to the web browser. Once it is sent, the server is done, and the PHP code is “gone.” The only way to run more PHP code is to request a new page, where the process starts over.

    (Even AJAX follows the same principles, although generally then you are dealing with partial data requests as opposed to full page views.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a PHP script that reads from a pipe in blocking mode. while($input
I read data from a mysql database that has is filled by php scripts.
I have a written a script in PHP that reads from data from a
I have a php file that reads data from my mysqldb as a json
HI, I have code like this. what I am doing is populating the first
I've created a PHP script that reads from beanstalkd and processes the jobs. No
I have bought a Joomla template from Template monster. It looks like this template
I have a script called at the end of an html page like this.
I have a Zend/PHP script that reads rows from a table in one MySQL
Hi i'm using this code to fetch new images from a folder to populate

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.