Random Record

Results 1 to 2 of 2

Thread: Random Record

  1. #1
    Join Date
    Dec 1969

    Default Random Record

    I'm wondering if it is possible to pull a single random record from a database, what I would like to do is set up about 100 or 200 join keys/codes. When a user attempts to join the site it stores their information in a pending users table, with a random join code and sends that join code to them in an email. When they return and supply their username and joincode, it will write their information to the regular users table. How would I go about pulling that random join code from the database, or is there an easier alternative to solving this??

  2. #2
    Aaron Moronez Guest

    Default RE: Random Record

    I don&#039;t think you need to pull a random record from a database- you just need to store enough information to identify a user when he/she comes back. From your example, your "pending" table just needs to store their username, email address, and join code. When the user comes back and enters their information, you might do a query like:<BR><BR>SELECT *<BR>FROM PENDING_USERS<BR>WHERE USERNAME = &#039;&#060;%username_input%&#062;&#039;<BR>AND JOINCODE = &#039;&#060;%joincode_input%&#062;&#039;<BR>AND EMAILADDRESS = &#039;&#060;%emailaddress_input%&#062;&#039; // optional =)<BR><BR>Assuming you have stored those in the database, you can pull up that specific record (and any info associated with it) with no problems. If you don&#039;t get any records, this person either didn&#039;t signup or entered info incorrectly. On a side note, I&#039;ve often found that using email addresses as usernames works well because you are assured that they will be unique. (Granted, you probably check for uniqueness before a db insert anyway, but this reduces the number of times you have to do that. Plus, you don&#039;t have to suggest an available name: "I&#039;m sorry, &#039;mike&#039; is taken, would you like mike29740?"). Once you have identified the "pending" user, you can go from there...

Posting Permissions

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