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 8841213
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T10:39:27+00:00 2026-06-14T10:39:27+00:00

Near the top of my script below the session_start(); I have this code below:

  • 0

Near the top of my script below the session_start(); I have this code below:

    if (isset($_POST['id'])) {

    $_SESSION['id'] = $_POST['id'];

    }

    if(isset($_SESSION['sessionNum'])){
                //Declare my counter for the first time

                $_SESSION['initial_session'] = $_SESSION['sessionNum'];
                $_SESSION['sessionNumber'] = intval($_SESSION['sessionNum']);
                $_SESSION['sessionCounting'] = 1;

        }

    elseif (isset($_POST['submitMarks']) && $_SESSION['sessionCounting'] < $_SESSION['sessionNumber']) {
        $_SESSION['sessionCounting']++;
    }

    $sessionMinus =  $_SESSION['sessionCounting'];
    $sessionConcat =  $_SESSION['sessionCounting'];


    if ($sessionMinus == $_SESSION['initial_session']){ 

        $action = 'infopenaltymarks.php'; 

    }elseif($sessionMinus != $_SESSION['initial_session']){ 

        $action = $_SERVER['PHP_SELF']; 

    }

$assessment = $_SESSION['id'] . $sessionConcat;

Now for the heading of the page I am using this code:

<h1>INDIVIDUAL MARKS FOR EACH ANSWER: ASSESSMENT (<?php echo $assessment ?>) <?php echo $sessionMinus ?> OF <?php echo $_SESSION['initial_session'] ?></h1>

Now lets say the Session Table in the database looks like this below:

SessionId  SessionName
1          AAA1
2          AAA2
3          AAB

Now if you look at the table above I have multiple exams AAA1 and AAA2 and I have a single exam AAB.

Now lets say I am working on Exam AAA1, it will display the heading as below:

INDIVIDUAL MARKS FOR EACH ANSWER: ASSESSMENT (AAA1) 1 OF 2

The above heading is correct as it displays the correct exam name, and it states its the first out of the two AAA exams

When I submit the page, it will change the heading to go on the second AAA exam which is below:

INDIVIDUAL MARKS FOR EACH ANSWER: ASSESSMENT (AAA2) 2 OF 2

Again the above heading is correct.

The problem I have is if I have a single exam, or in this case the exam AAB, as it is a single exam, it does not contain a number at the end of the exam name so it is simply displayed as AAB in the DB.

But when I output the heading it displays this below:

INDIVIDUAL MARKS FOR EACH ANSWER: ASSESSMENT (AAB1) 1 OF 1

Now you can see that the above heading is incorrect as it is not exam AAB1, it should be AAB in between the brackets. So what my question is that if an exam is 1 OF 1 or in other words just a single exam, how can I remove the number 1 from the end of the exam name in between the brackets so it displays it as AAB and not AAB1?

  • 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-14T10:39:28+00:00Added an answer on June 14, 2026 at 10:39 am

    Add the session count only if greater than 1

    $assessment = $_SESSION['id'];
    if ($_SESSION['initial_session'] > 1) {
        $assessment .= $sessionConcat;
    }
    

    Fix right before printing the line

    <?php
    if ($_SESSION['initial_session'] == 1) {
        $assessment = substr($assessment, 0, -1);
    }
    ?>
    <h1>INDIVIDUAL MARKS FOR EACH ANSWER: ASSESSMENT (<?php echo $assessment ?>) <?php echo $sessionMinus ?> OF <?php echo $_SESSION['initial_session'] ?></h1>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two PHP scripts which both have an include_once('authentication.inc'); script near the top.
Near the top of my page, I have this: <?php $id = $_GET['id']; ?>
I have a Perl script that sets up variables near the top for directories
I have a big Sweave file with a variable called specialty near the top.
In my application i'm declaring a string variable near the top of my code
This will position the box a little below the top <div style=height: 10em; width:
I added the following command near the top of my shell script in order
Is this valid C++ (considering the latest standard)? I'm getting compilation errors with near-top-of-tree
All my constants are near the top of my javascript file like below. When
near the top of the code i see things like, btn_dropdown._visible = false; mcMenuBkg._visible

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.