Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Re-Run Function Button?

Name: Anonymous 2009-07-30 3:23

Yesterday I started writing a script to generate random information which I could use to create NPCs for my Dungeons and Dragons games. I decided that if I was going to be unattractive to women, I may as well not hold back, ya know?

Anyway, I've never actually coded in PHP before, so this has been a bit of a struggle. But things are coming along at a decent pace. I've managed to complete all but one of the tasks I set out to complete in version 2 of the script.

I want the user to be able to "re-roll" one of the variables if they don't like the result, or if the result is incompatible with one of the other results. But I've been trying to solve this problem off and on for the last six hours or so, without any significant breakthroughs.


<?php

//BEGIN RANDOM ALIGNMENT
   
    function align_rand($align){
        $g = $align[mt_rand(1, 3)];
        $l = $align[mt_rand(4, 6)];

        if($g=="Neutral" && $l=="Neutral"){
            $ment = "True Neutral";
        }
        else{
            $ment = $g." ".$l;
        }

        return $ment;

    }

//END RANDOM ALIGNMENT

?>

    <br /><br /><b>Alignment is: </b>
    <?php echo align_rand($align); ?>


If possible I'd like for the "re-roll" button to take the form of a hyperlink rather than a button, but whatever gets the job done at this point is fine with me.

Again, any help would be greatly appreciated. Thank you in advance, and I eagerly await your response.

Name: Anonymous 2009-07-30 3:53

$_POST and $_GET and go away.

Name: Anonymous 2009-07-30 4:03

>>2
Don't forget $_SESSION.

Name: Anonymous 2009-07-30 4:28

Why are you programming in php without knowing about session variables 'n cookies?

Name: Anonymous 2009-07-30 8:11

That reminds me, I've been wondering, what language should I learn to pick up teh chickz0rz? I'm thinking something hip, like Python, or Rupy on Rail!
I know a lot of girls dig older respectable types, but I don't have the greying beard I'd need to pull off the COBOL look.

Name: Anonymous 2011-02-03 7:39

<

Name: Anonymous 2011-02-04 13:21


Don't change these.
Name: Email:
Entire Thread Thread List