Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2006

    Question Unanswered: Random number, then remove from a list

    A bit of background.

    I run a fishing website, normally when we have a Match at a lake, we pull our peg numbers from a bag and thats the peg you fish for the day.

    However, people are arriving at seperate times, so we are trying to do this online.

    So in english this is what im trying to achive.

    On a lake there are say 32 pegs, so my array is (1,2,3,4,5.etc to.32) I want the user to complete a form, and the script to randomly select one of the above numbers, data returned is "David" "Peg 5".

    I need David and his peg (5) to be logged into a MySQL database and the number 5 to disapear from my array.

    Any help to kick me off would be most appriciated. Im not fantastic with PHP but I know a bit, I just cant seem to get started!

    Thanks in advance

  2. #2
    Join Date
    Jul 2004
    Dundee, Scotland
    can you use a database? I'd approach this by putting the pegs in a database table. then randomly retrieve a peg which is available. when a random reg is retrieved, update the table to say that is it no longer available.

    here is some example SQL (MySQL) code that I used to for something else: "SELECT fieldname FROM tablename WHERE category='$category' AND hide='N' ORDER BY rand() limit 0,10 "

Posting Permissions

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