<?
require("config.php");
$dbh = mysql_connect ($conf[dbhost], $conf[dbuser], $conf[dbpass]) or die (mysql_error());
mysql_select_db ($conf[dbname]);
srand((double)microtime() 10000000);
$getemail = "SELECT FROM people ORDER BY RAND()";
$getemail2 = mysql_query($getemail) or die("Could not get email");
$out = array();
while($row = mysql_fetch_array($getemail2)) {
$id = $row[id];
$i = 1;
while($i < $row[amount]) {
$out[] = $row[email];
$i++;
} // loop all people
}
$rand_keys = array_rand($out, 1);
$email = $out[$rand_keys];
/ debug block VERY LAGGING
echo "<pre>";
print_r($out);
print_r($rand_keys);
echo "\n".$email;
echo "</pre>";
/
header("location: index.php?id=".$email);