Results 1 to 7 of 7

Thread: [RESOLVED] Random Numbers

Threaded View

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Mar 2006
    Posts
    31

    [RESOLVED] Random Numbers

    I'm pulling my hair, I'm just creating a bunch of different little experiments and little fun projects right now. I've got a Deal or No Deal thing that's going very well. I'm trying to create some XML/PHP dealies. And my last one is the where I hit a snag. I'm trying to create a Black Jack game, but my random number generator doesn't seem to be working right. Here's my code: {it's completely unfinished and I only started creating it.}

    PHP Code:
    session_start();

    if(!isset(
    $_SESSION['suite'])){    
              
    $_SESSION['suite'] = array("Hearts""Diamonds""Clubs","Spades");
    }

    if(!isset(
    $_SESSION['number']))
    {    
              
    $_SESSION['number'] = array("Two""Three""Four""Five""Six""Seven""Eight""Nine""Ten",    "Jack""Queen""King""Ace");
    }

    if(!isset(
    $_SESSION['cards']))
    {    
              
    $_SESSION['cards'];
    }

    function 
    showCard()
    {
              
    $suite $_SESSION['suite'][rand(03)];
              
    $number $_SESSION['number'] [rand(012)];
              return 
    $number .' of '$suite;
    }

    function 
    addToCardsArray($card){    
              
    $_SESSION['cards'][] = $card;
    }

    echo 
    '<form action="mypage.php">';
    echo 
    showCard() .'<br>';
    echo 
    showCard();
    echo 
    '</form>'
    The reason I say it doesn't work is that everytime I refresh my page, it returns the same card. Every once in a while it changes, but that happens after a minute or so, so it's not helpful at all.
    Last edited by Ataru Moroboshi; Oct 15th, 2007 at 04:50 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width