title: Select raffle ticket winners
body: <p>I've created a script where users can get points by completing tasks and then the more points they get the higher chance they have of winning the prize.
  It works like a raffle ticket competition.</p>
  
  <p>My problem is generating winners.</p>
  
  <p>I can choose a random winner with a code like this:</p>
  
  <pre><code>    function selectWinners($count){
      $select = mysql_query("SELECT first_name from `users` ORDER BY RAND() LIMIT {$count}");
      $results = mysql_fetch_assoc($select);
      echo "Winner is {$results[first_name]}";
      }
  </code></pre>
  
  <p>But this is just completely random and doesn't matter at all as to how many points the users have. </p>
  
  <p>I believe I've got to create a temporary table that shows the users ID for every point they have, then use a similar script to select a random ID?</p>
  
  <p>I'm not entire sure, just a guess, I also don't have a clue how that would be coded.</p>
  
  <p>Thanks</p>