<?php
include('dbinfo.php');

$rsCandidate = mysql_query("SELECT * FROM candidate WHERE site_id=1");
while($rwCandidate = mysql_fetch_array($rsCandidate)){
$candidate_id = $rwCandidate['candidate_id'];  
$candidateArray[$candidate_id] = $rwCandidate['applicant_id'];  
}
//echo "<pre>"; print_r($candidateArray);die;
foreach($candidateArray as $k=>$v){
$length = 10;
$randomString = substr(str_shuffle("ABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, $length);
mysql_query("INSERT INTO candidate_code(candidate_id, applicant_id, code)VALUES('$k', '$v', '$randomString')");
}
?>
