<?php
$tahun = date('y');
  $bulan = date('m');
  $hari = date('d');
  $rand = rand(1, 9999);
  $char = "rt";
  $newID = $char.sprintf($tahun).sprintf($bulan).sprintf($hari).sprintf("%04s", $rand);

  $cekid=mysqli_num_rows(mysqli_query($conn, "SELECT * FROM santri_rt WHERE id_santri='$newID'"));
  ?>