<?php
foreach($eleves as $eleve) {
	do {
		$chn = '';
		for ($i=1;$i<=$intbc;$i++) {
		    $chn .= rand(0, 9);
		}
		$check_code = mysqli_num_rows(mysqli_query($bdd,"SELECT code FROM ".$prefix."_eleves WHERE code LIKE '%".$chn."'"));
		$check_user = mysqli_num_rows(mysqli_query($bdd,"SELECT login FROM ".$prefix."_user WHERE login LIKE '%".$chn."'"));
	}
	while($check_code==1||$check_user==1);
	mysqli_query($bdd,"UPDATE ".$prefix."_eleves SET code = '".$txtbc.$chn."' WHERE eleves_id = '".$eleve['eleves_id']."'");
}
?>