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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T21:09:52+00:00 2026-06-01T21:09:52+00:00

So I want to create a script where out of about ten mysql functions

  • 0

So I want to create a script where out of about ten mysql functions that give a user a different item, whenever the user clicks on the page, one of those functions is executed at random.
It’s kind of an rpg function I need, where depending on the user’s level with hunting, they are more successful, but won’t always get food. So they click on the page and from an array of items, one is at random returned and that item given to them via a mysql_query.

I hope that makes sense, if not, let me know…

so far I’ve got these starting points

$input = array("value 1", "value 2", "value 3", "value 4", "value 5");
 $rand_keys = array_rand($input, 1);
 echo $input[$rand_keys[0]] . "\n";

I don’t know if this would allow mysql queries in the array though.
I’ve also thought about using a redirect thing, but the one I tried kept redirecting, which was not what i wanted, and urls can be tampered to get the good result with that…

Anyway, I hope that made sense and any help would be greatly appreciated 🙂

  • 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-01T21:09:54+00:00Added an answer on June 1, 2026 at 9:09 pm

    I would tackle this challenge by having a table with the items and it’s values. One of the columns would be prio_drop. If you want a certain item to be dropped more often it can have value 2 while the others have value 1. The higher value, the greater chance.

    Then I’d do a:

    $arr_items = array(1, 2, 3, 5); /* This event can drop items with these ids */
    $str_items = implode(', ', $arr_items);
    
    mysql_query("
    SELECT id, name
    FROM items
    WHERE id IN ({$str_items})
    ORDER BY (RAND() * prio_drop) DESC
    LIMIT 1
    ");
    

    Hope I understood you correctly?

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

Sidebar

Related Questions

I want to create super script for desired text selected by user. I found
I'm a student from indonesia and I want to create an script that deletes
JavaScript. I want to create simple script, that will be resize loaded image using
I want to create a powershell script that creates a shortcut in the windows
I want to create an SQL script that creates a database. Right now, I
I want to create an application in Apps Script that would fetch my Latitude
I have a Silverlight solution that I want to create a build script for.
I want to create script to edit photos in galery. I have there textbox
I want to create a deployment script, somehow emulate Oracle deployment scripts, where with
I want to create an HTTPURLConnection to a PHP script and get the HTTP

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.