Anda di halaman 1dari 2

<!

doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
</head>

<body>
<p>&lt;?php<br>
require_once(&quot;../fns/siteFunction.php&quot;);<br>
session_start();</p>
<p>//authenticated();<br>
$sUserID=$_SESSION[&quot;sUserID&quot;];<br>
$temp=&quot;&quot;;<br>
$x1=1;<br>
$x2=0;<br>
$x3=1;<br>
$x=1;<br>
function getNRM($con,$x1,$x2,$x3,$x){<br>
$f='blm ketemu';<br>
$rm=tambahNol($x1).&quot;.&quot;.tambahNol($x2).&quot;.&quot;.tambahNol($x3);<br>
$q=&quot;SELECT COUNT(*) FROM pasien WHERE rm='$rm'&quot;;<br>
//echo $q.&quot;&lt;br&gt;&quot;;<br>
//echo &quot;RM $rm &quot;;</p>
<p> $result = $con-&gt;query($q); <br>
$data = $result-&gt;fetch_array();<br>
//echo &quot;---&gt; &quot;.$data[0].&quot; &lt;br&gt;&quot;; <br>
if($data[0]==0){<br>
$f='ketemu';<br>
$rm=tambahNol($x1).&quot;.&quot;.tambahNol($x2).&quot;.&quot;.tambahNol($x3);<br>
$temp=$rm;<br>
//echo &quot;$f&quot;;<br>
return $temp;<br>
}<br>
<br>
while($f!='ketemu'){<br>

$x++;<br>
<br>
if($x3&lt;99){<br>
$x3++;<br>
}else{<br>
if($x2&lt;99){<br>
$x2++;<br>
$x3=1;<br>
}else{<br>
$x1++;<br>
$x2=0;<br>
$x3=1;<br>
}<br>
} <br>
$rm=$x1.&quot;.&quot;.$x2.&quot;.&quot;.$x3;<br>
//echo &quot;loop ke $x &lt;br&gt;&quot;;<br>
return getNRM($con,$x1,$x2,$x3,$x);<br>
}<br>
<br>
<br>
}<br>
$temp=getNRM($con,$x1,$x2,$x3,0);<br>
$id=getNextID($con,&quot;id&quot;,&quot;pasien&quot;);<br>
$q=&quot;INSERT INTO pasien VALUES ('$id','$temp','','','','','','','','','','','','',NOW())&quot;;<br>
$result = $con-&gt;query($q); <br>
if($result){<br>
echo $temp;<br>
}else{<br>
echo &quot;Mohon reload page!&quot;;<br>
}</p>
<p>?&gt;</p>
</body>
</html>

Anda mungkin juga menyukai