im writing a php simple code that read from a file and search for an student degree from that file. for example in my file i have:
123 20
456 18
789 19
and i want to show for example '123' degree in an alert box whith this code:
<?php
function show_degree($str) {
echo '<script type="text/javascript">alert("' . $str . '")</script>';
}
$given_number="123";
$myfile = fopen("degree/dm.txt", "r");
while (($line = fgets($myfile)) !== false) {
list($number, $degree) = explode("\t", $line);
if($number==$given_number) {
echo $degree;
show_degree( 'Hello:\
\
Your Degree:\
'.$degree );
}
}
fclose($myfile);
?>
what should i do? tnx a lot