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 🙂
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 value2while the others have value1. The higher value, the greater chance.Then I’d do a:
Hope I understood you correctly?