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

  • Home
  • SEARCH
  • 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 8178267
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T23:43:19+00:00 2026-06-06T23:43:19+00:00

In my code below, why is it not incrementing the integers by one each

  • 0

In my code below, why is it not incrementing the integers by one each time? For example, say I have 1 OF 5 when I submit the form. After submission, it should be 2 OF 5, but instead, it displays 5 OF 5. This occurs even if I change the maximum from 5 to 3; it starts at 1 OF 3 and jumps immediately to 3 OF 3. This is the code to display the .. OF ..

<h1><?php echo $sessionMinus ?> OF <?php echo $_SESSION['initial_count'] ?></h1>

Below is the code which should increment the value by one each time:

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

  $_SESSION['initial_count'] = $_POST['sessionNum'];
  $_SESSION['sessionNum'] = $_POST['sessionNum'];
  $_SESSION['sessionCount'] = 1;
}
else if ($_SESSION['sessionCount'] < $_SESSION['sessionNum']) {
    $_SESSION['sessionCount']++;
}

$sessionMinus =  $_SESSION['sessionCount'];
  • 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-06T23:43:20+00:00Added an answer on June 6, 2026 at 11:43 pm

    The code looks fine. However it is possible that the page is being requested in the background without your knowing. For instance a broken image path etc could be landing on this file hence incrementing your counter. To make sure thats not the case, add a new session array var which records the $_SERVER['REQUEST_URI'] or log it to a text file or something.

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

Sidebar

Related Questions

Background: I have a WPF UserControl (MainControl - not shown in code below) that
I've got a Model in Django, example code below (not my actual code): class
I have the following problem illustrated by the pseudo code below (might not make
The code below does not work but meant to illustrate what I want to
Below code not work, but it's work fine for jsf1.2. Now the framework is
W.r.t code below I can not declare the type of fetch-into-variable as the underlying
The code below produces an error saying that my input string was not in
Getting vector iterator not deferencable for code below, but I don't see why. I
I've encountered code below and I'm not fully sure what it's achieving. I think
The code below is working, but with a problem I do not understand. When

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.