Kamata Kamata - 1 month ago 5x
PHP Question

processing form multiple times

I'm helping to create a small 'game' where you will be able to take the traits from a male/female animal and create their offspring.

In the form you tell it what fur type/color etc the mother/father have and using random numbers it will generate the offspring.

However I need to generate a random amount of offspring, therefor I need to generate a random number and have the form create that many results!
Here's how a simple version of it looks for just one result: http://lostfables.com/counter/home.php

Here is the code: http://pastebin.com/tBcNUSex

How do I essentially have that form be submitted multiple times depending on the random number I assign?


You will need an extra variable for random $numberOfIterations and to wrap your logic code with a for loop. This will recreate the logic code business according to random $check for deciding on the current attribute, and at the end of every iteration it will print the current result.

    // We want a random number between 1-200 and put it in the variable $check
    // Random number of loop times
    $numberOfIterations = rand(1,200);

    for ($i = 0; $i < $numberOfIterations; $i++) {
        // Random number for generating attributes.
        $check = rand(1,200);

        // All the logic code in here
        // ..
        // End of logic code

        echo '<br/><br/>';
        echo $check.'<br/>';
        echo $coats;