title: select random entry using two columns
body: <p>I created a contest where people who refer others increase their odds of winning with each referral. Now I have to figure out how to use mysql or php to actually give them better odds. Selecting a random row won't cut it. </p>
  
  <p>In my table I have two columns, one for ID and one for the referral ID. The table keeps track of who referred whom by adding the ID into the referral ID field, so the first few rows of data looks like this:</p>
  
  <pre><code>name   id  referralid 
  mark   15   20 
  ted    20 
  jim    22   20
  </code></pre>
  
  <p>So 'ted' should have 3 chances to win since he referred two other people. How can I do this in mysql or php?</p>