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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T11:05:18+00:00 2026-06-07T11:05:18+00:00

i am trying to execute a random query … at random 1-15 attacks The

  • 0

i am trying to execute a random query … at random 1-15 attacks
The below is a php query for a game.
it gets executed when a player hits the attack button. i simplified the query for simplicity’s sake.

In other words what im trying to do is///

randomly every 10 attacks to this specific ship_id run the query to insert

what i have so far is wrong in terms of the random generator but hopefully will make my point.

————————-The random hit would be below this line

        **function RandNumber($e){


  for($i=0;$i<$e;$i++){
  $rand =  $rand .  rand(0, 9);  
  }
  return $rand;

  }

  mysql_query("INSERT INTO {$game}_ships (ship_name,login_name,shipclass,class_name,class_name_abbr,fighters,max_fighters,max_shields,cargo_bays,mine_rate_metal,mine_rate_fuel,config,size,upgrades,move_turn_cost,point_value,location,login_id
    ) values(
    'FC1','$user[login_name]','427','fc','  Sc','5967','5967','10442','2003','5','45','bs:dt:ot','6','99','19','45',1,'$user[login_id]')");
  echo "<div class='success'>427 </div>";**

anyone can point me in the correct direction?

  • 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-07T11:05:20+00:00Added an answer on June 7, 2026 at 11:05 am

    You need to track the hits if you want an exact number like every 10 hits, or every 9-15 hits.
    you track it by running inserting a query every hit

    mysql_query("INSERT INTO YOURTABLE SET hits=hits+1 LIMIT 1");
    

    then you fetch that same hits from the db and check whether it is 10

    if ($hits%10==0){INSERT YOUR QUERY IN QUESTION}
    

    but if you want just by random from 1-15 regardless of hits count then:

      $rand =  rand(1, 15);  //but I would go with 1,5  this will be totally random, I think tracking hits is better 
    
    
      if ($rand==1){
             mysql_query("INSERT INTO {$game}_ships (ship_name,login_name,shipclass,class_name,class_name_abbr,fighters,max_fighters,max_shields,cargo_bays,mine_rate_metal,mine_rate_fuel,config,size,upgrades,move_turn_cost,point_value,location,login_id
         ) values(
          'FC1','$user[login_name]','427','fc','  Sc','5967','5967','10442','2003','5','45','bs:dt:ot','6','99','19','45',1,'$user[login_id]')");
      echo "<div class='success'>427 </div>";
      }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to execute the following query in oracle but not able to
I'm trying to execute a script named csearch.php five times with the interval of
I am trying to execute a parameter query for a Postgre database using Springs
We are trying to execute a select query which uses a column name in
I am trying to execute this query against Oracle linked server, and getting the
Im trying to execute a SQL query that will rename the columns of a
I am trying to execute this SQL query prior to restoring a .BAK file
I am trying to execute a simple calculation (it calls Math.random() 10000000 times). Surprisingly
Trying to execute powershell script in my C# code. Using .NET Framework v. 4.0.30319
Im trying to execute a .bat file remotely in a powershell script. The code

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.