If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > PHP > need help with simple database

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-07-10, 14:54
sylmadison sylmadison is offline
Registered User
 
Join Date: Jul 2010
Posts: 2
need help with simple database

unsure how I can do this, i am fairly new at PHP, I am still learning and have self taught myself from reading ALOT.

My question is how can I have my registered users receive a code in their email a three digit code, that is pulled from a data base of 999 codes, that can only be used once? it selects a new code each time.
Also there will be referers so if code 011 refers a friend their friends will say yes 011 referred me and the database will keep track of any linked codes from referrals.

Seems way out of my league if anyone can help please let me know.
I appreciate all the help I can get thank you!

Sylvia
Reply With Quote
  #2 (permalink)  
Old 07-15-10, 17:41
R45 R45 is offline
Registered User
 
Join Date: Jul 2010
Location: Winnipeg, Canada
Posts: 7
Pretty simple, you have a couple options. One simple solution is to have a table with all the possible codes and a field for the username/id/identifier of the person who consumed the code.

For example, [code_id], [user_id]

As such, you can simply query the table for a row with an empty [user_id] to access a new unused code. Additionally, in the table with users (assuming you have one), keep a [referral_code] column with the code that the person was referred by. Subsequently you can aggregate referrals with simple queries thereafter.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On