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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T19:36:02+00:00 2026-05-23T19:36:02+00:00

Is there a way to run a PHP FUNCTION fun(); only once when a

  • 0

Is there a way to run a PHP FUNCTION “fun();” only once when a logged in user accesses a page multiple times?

here is the function.

<?php

$connect = //connect to database

function fun()
{

    //loop declare begin
    $quer = "SELECT * FROM sffedorvsdan WHERE username = '$_SESSION[username]'";

    if($quer_run = mysql_query($quer))
    {
        while($row = mysql_fetch_assoc($quer_run))
        {
            $pick1 = $row['pick1'];
            $pick2 = $row['pick2'];
            $pick3 = $row['pick3'];
            $pick4 = $row['pick4'];
            $pick5 = $row['pick5'];
            $pick6 = $row['pick6']; 

            //loop end EXCEPT CLOSE 

            $user = $_SESSION['username'];

            if($pick1 == '11')
            {

                $score = mysql_query("
                    UPDATE stats SET score = (score + 10), mmascore = (mmascore + 10), 
                    wins = (wins + 1), games = (games + 1)
                    WHERE username = '$user'
                ");

                return $score;
            } 
            else if($pick1 == '21')
            {
                $score2 = mysql_query("
                    UPDATE stats SET score = (score - 5), mmascore = (mmascore - 5), 
                    games = (games + 1)
                    WHERE username = '$user'");

                return $score2;
            }
        }
    }else{
        echo mysql_error();
    }
}

?>
  • 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-05-23T19:36:03+00:00Added an answer on May 23, 2026 at 7:36 pm

    Using authentication/sessions and storing the number of times a user has accessed that page in say a database for example or a flat file. You’ll need to persist their access count to that page regardless.

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

Sidebar

Related Questions

Is there a way to tell PHP to run one last function, or somehow
Is there a way I can run a php function through a JS function?
I am wondering if there is a way to specify a php function or
Normally php script continues to run after E_NOTICE, is there a way to elevate
I have a php function that's run when a build.php page is loaded and
Is there a way run Emacs from a USB drive? I am a Windows
Is there a way to run a regexp-string replace on the current line in
Is there a way to run some custom Javascript whenever a client-side ASP.NET validator
Is there a way to run an Amazon EC2 AMI image in Windows? I'd
Is there a way to run a project inside a solution that has more

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.