Penilaian dengan huruf

ulfa · Aug 7, 2012
master2 php minta bantuane akumembuat sistem informasi sekolah, dan waktu membuat scrip nilai di ubah menjadi huruf, tapi k error terus, mohon bantuan y :) ini scrip y
<?php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Rangking</title>
<style type="text/css">
<!--
.style38 {font-size: 16px}
.style5 {color: #FF0000; font-weight: bold; font-size: 18px; font-family: "Times New Roman", Times, serif; }
-->
</style>
</head>

<body>
<table width="634" border="1" align="center" bordercolor="#0000FF">
  <tr>
    <td colspan="6"><div align="center"><span class="style5">Hasil</span></div></td>
  </tr>
  <tr bgcolor="#666666">
    <td width="105" class="style15"><div align="center" class="style23 style38">No</div></td>
    <td width="105" class="style15"><div align="center" class="style23 style38">Nip</div></td>
    <td width="133" class="style15"><div align="center" class="style23 style38">Nama</div></td>
    <td width="142" class="style15"><div align="center" class="style23 style38">Jurusan</div></td>
    <td width="40" class="style15"><div align="center" class="style23 style38">Total</div></td>
    <td width="69" class="style15"><span class="style23 style38">Rangking</span></td>
  </tr>
  <?php 
  $koneksi=mysql_connect("localhost", "root", "")
                     or die ("Gagal konek server".mysql_error());
                     mysql_select_db("spk",$koneksi)
                     or die ("Database gagal dibuka".mysql_error());
                     
  $ranking=mysql_query("select nip,nama,jurusan,total from hasil order by total desc");  
              $nip=$_POST['nip'];
            $nama=$_POST['nama'];
            $jur=$_POST['jurusan'];
            $total=$_POST['total'];

             
             
   if($total[$no]>=85) {$huruf[$no]='A'; $color='blue';} 
   elseif($total[$no]>=70) {$huruf[$no]='B'; $color='blue';} 
   elseif($total[$no]>=55) {$huruf[$no]='C'; $color='blue';} 
   elseif($total[$no]>=40) {$huruf[$no]='D'; $color='blue';} 
   else {$huruf[$no]='E'; $color='red';} 
  
?>
  <tr>
    <td><?php echo $no;?></td>
    <td><?php echo $nip;?></td>
    <td><?php echo $nama;?></td>
    <td><?php echo $jurusan;?></td>
    <td><?php echo $total;?></td>
    <td><?php echo $total[$no]?></td>
  </tr>
  <?php 
  $no++; 
} 
?>
</table>
</body>
</html> ?>
Silahkan login untuk menjawab!
0
Loading...
ulfa · Aug 10, 2012 · 0 Suka · 0 Tidak Suka
jadi erd y ntar ngikuti DB y mas...... :)
1
Loading...
Ellyx Christian · Aug 12, 2012 · 1 Suka · 0 Tidak Suka
saya masalah kamu ada di

$sql="select nip,nama,jurusan,total from hasil order by total desc";
$qry = mysql_query($sql, $koneksi) or die ("Query Gagal ".mysql_error());
$nip=$_POST;
$nama=$_POST;
$jur=$_POST;
$total=$_POST;

yang kamu bandingkan adalah nilai dari $_POST yang nilainya adalah nol, jadi semuakan akan dapat E. Seharusnya
<?php 
$koneksi=mysql_connect("localhost", "root", "") or die ("Gagal konek server".mysql_error());
mysql_select_db("spk",$koneksi) or die ("Database gagal dibuka".mysql_error());

$sql="select nip,nama,jurusan,total from hasil order by total desc"; 
$qry = mysql_query($sql, $koneksi) or die ("Query Gagal ".mysql_error()); 
while($data=mysql_fetch_array($qry)){
	$total = $data['total'];
	if($total>=85) {
		$huruf='A'; $color='blue';
	} elseif($total>=70) {
		$huruf='B'; $color='blue';
	} elseif($total>=55) {
		$huruf='C'; $color='blue';
	} elseif($total>=40) {
		$huruf='D'; $color='blue';
	} else {
		$huruf='E'; $color='red';
	} 
	?>
	<tr>
	<td><?php echo $data['no'];?></td>
	<td><?php echo $data['nip'];?></td>
	<td><?php echo $data['nama'];?></td>
	<td><?php echo $data['jurusan'];?></td>
	<td><?php echo $data['total'];?></td>
	<td bgcolor="<?php echo $color;?>"><?php echo $huruf;?></td>
	</tr>
<?php   $no++; 
}
?>
0
Loading...
ulfa · Aug 12, 2012 · 0 Suka · 0 Tidak Suka
matur thank you mas allyx, dikasih variabel $total = $data; :D
oy mas mw nanya, ak kan membuat select option yg nanti jika dipilih option y secara otomatis keluar poin ditextfield dan jika disave didatabse akn masuk 2 value yaitu pendidikan dan poin y? tolong y mas..!!
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<script type="text/javascript">
function didik(){
var a;
a = parseFloat(form1.op1.value);
if (isNaN(a))
a=0.0;
document.getElementById('poin').value = poin;
form1.poin.value = a;
}
</script>

<body>
<form id="form1" name="form1" method="post" action="" onSubmit="return checkForm(this)">
  <table width="557" border="0">
    <tr>
      <td width="141" nowrap="nowrap" class="style10"><strong>Pendidikan Terakhir </strong></td>
      <td width="151"><strong>:</strong>
          <select name="op1" onclick="didik()" id="op1">
            <option value="" selected="selected">.::Pilih::.</option>
            <option value="1">SMA</option>
            <option value="2">D1</option>
            <option value="3">D2</option>
            <option value="4">D3</option>
            <option value="5">S1</option>
            <option value="6">S2</option>
            <option value="7">S3</option>
        </select></td>
      <td width="38">poin</td>
      <td width="209"><input type="text" id="poin" name="poin" readonly="readonly" /></td>
    </tr>
  </table>
</form>
</body>
</html>
1
Loading...
Ellyx Christian · Aug 12, 2012 · 1 Suka · 0 Tidak Suka
<?php
if($_POST){
$op1 = explode('-',$_POST['op1']);
$pendidikan = $op1[1];
$poin = $op1[0];
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<script type="text/javascript">
function didik(){
var a;
a = document.getElementById('op1').value.split('-');
document.getElementById('poin').value = a[0];
}
</script>
 
<body>
<form id="form1" name="form1" method="post" action="" onSubmit="return checkForm(this)">
  <table width="557" border="0">
    <tr>
      <td width="141" nowrap="nowrap" class="style10"><strong>Pendidikan Terakhir </strong></td>
      <td width="151"><strong>:</strong>
          <select name="op1" onchange="didik()" id="op1">
            <option value="" selected="selected">.::Pilih::.</option>
            <option value="1-SMA">SMA</option>
            <option value="2-D1">D1</option>
            <option value="3-D2">D2</option>
            <option value="4-D3">D3</option>
            <option value="5-S1">S1</option>
            <option value="6-S2">S2</option>
            <option value="7-S3">S3</option>
        </select>
        </td>
      <td width="38">poin</td>
      <td width="209"><input type="text" id="poin" value="0" name="poin" readonly="readonly" /></td>
    </tr>
  </table>
</form>
</body>
</html>
0
Loading...
ulfa · Aug 13, 2012 · 0 Suka · 0 Tidak Suka
maap mas maksud ak yg poin y di select option, & pendidikan y di text field,
t coba2 scrip dari mas ellyx masuk ke textfield y, tapi di poin total tidak bertambah mas, Mohon pencerahan y mas ???
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
    <?php
    if($_POST){
    $op1 = explode('-',$_POST['op1']);
    $pendidikan = $op1[1];
    $poin = $op1[0];
	$p = $op1[0];
    }
    ?>
  <script type="text/javascript">
    function dik(){
    var a;
    a = document.getElementById('op1').value.split('-');
    document.getElementById('poin').value = a[0];
    }
    </script>
<script type="text/javascript">
function didik(){
var b,c,d;
b = parseFloat(form1.op2.value);
if (isNaN(b))
b=0.0;
c = parseFloat(form1.op3.value);
if (isNaN(c))
c=0.0;
d = parseFloat(form1.op4.value);
if (isNaN(d))
d=0.0;
document.getElementById('top').value = top;
form1.top.value = b + c + d;
}
</script>
<body>
<form id="form1" name="form1" method="post" action="" onSubmit="return checkForm(this)">
  <table width="478" border="2" align="left" bordercolor="blue" style="border-collapse: collapse; border-style:dashed">
    <tr>
      <td><table width="465" border="0">
          <tr>
            <td width="154" nowrap="nowrap" class="style10"><strong>Pendidikan Terakhir </strong></td>
            <td width="301"><strong>:</strong>
                <select name="op1" onchange="dik()" id="op1">
                  <option value="" selected="selected">.::Pilih::.</option>
                  <option value="SMA-1">SMA</option>
                  <option value="D1-2">D1</option>
                  <option value="D2-3">D2</option>
                  <option value="D3-4">D3</option>
                  <option value="S1-5">S1</option>
                  <option value="S2-6">S2</option>
                  <option value="S3-7">S3</option>
                </select>
              <label> <strong>Pend : </strong>
                <input name="poin" type="text" id="poin" value="lulusan" size="5" maxlength="5" readonly="readonly" />
                <strong>Poin : </strong>
                <input name="pendidikan" type="text" size="5" maxlength="5" />
              </label></td>
          </tr>
          <tr>
            <td nowrap="nowrap" class="style10">Fak/ Jurusan </td>
            <td><label><strong>:</strong>
                  <input name="jur" type="text" id="jur" />
              </label>
                <strong>=&gt;</strong>
                <select name="op2" onclick="didik()" id="op2">
                  <option value="" selected="selected">.::Pilih::.</option>
                  <option value="1">1</option>
                  <option value="2">2</option>
                  <option value="3">3</option>
                  <option value="4">4</option>
                  <option value="5">5</option>
                  <option value="6">6</option>
                  <option value="7">7</option>
              </select></td>
          </tr>
          <tr>
            <td nowrap="nowrap" class="style10"><strong>Lulusan Dari</strong></td>
            <td><label><strong>:</strong>
                  <select name="op3" onclick="didik()" id="op3">
                    <option value="" selected="selected">.::Pilih::.</option>
                    <option value="7">Negeri Akreditasi A</option>
                    <option value="6">Negeri Akreditasi B</option>
                    <option value="5">Negeri Akreditasi C</option>
                    <option value="4">Swasta Akreditasi A</option>
                    <option value="3">Swasta Akreditasi B</option>
                    <option value="2">Swasta Akreditasi C</option>
                    <option value="1">Swasta Non Akreditasi</option>
                  </select>
            </label></td>
          </tr>
          <tr>
            <td nowrap="nowrap" class="style10"><strong>Lulus Tahun </strong></td>
            <td><strong>:</strong>
                <select name="op4" onclick="didik()" id="op4">
                  <option value="" selected="selected">.::Pilih::.</option>
                  <option value="7" id="op3">Tahun Ini</option>
                  <option value="6" id="op3">Tahun Lalu</option>
                  <option value="5" id="op3">2 Tahun Lalu</option>
                  <option value="4" id="op3">3 Tahun Lalu</option>
                  <option value="3" id="op3">4 Tahun Lalu</option>
                  <option value="2" id="op3">5 Tahun Lalu</option>
                  <option value="1" id="op3">Lebih Dari 5 Tahun Lalu</option>
              </select></td>
          </tr>
          <tr>
            <td><strong>Asal Pendidikan </strong></td>
            <td><label> <strong>: </strong>
                  <input name="asal" type="text" id="asal" />
            </label></td>
          </tr>
          <tr>
            <td>&nbsp;</td>
            <td><strong><span class="style18"><span class="style8 style2">Total </span>: </span>
                  <input name="top" type="text" id="top" size="4" maxlength="4" value="" readonly="readonly"/>
            </strong></td>
          </tr>
      </table></td>
    </tr>
  </table>
</form>
</body>
</html>
1
Loading...
Ellyx Christian · Aug 14, 2012 · 1 Suka · 0 Tidak Suka
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
    <?php
    if($_POST){
    $op1 = explode('-',$_POST['op1']);
    $pendidikan = $op1[1];
    $poin = $op1[0];
    $p = $op1[0];
    }
    ?>
  <script type="text/javascript">
    function dik(){
    var a;
    a = document.getElementById('op1').value.split('-');
    document.getElementById('poin').value = a[1];
    document.getElementById('pendidikan').value = a[0];
      didik();
    }
    </script>
<script type="text/javascript">
function didik(){   
var a,b,c,d;
a = parseFloat(document.getElementById('poin').value);
if (isNaN(a))
a=0.0;
b = parseFloat(form1.op2.value);
if (isNaN(b))
b=0.0;
c = parseFloat(form1.op3.value);
if (isNaN(c))
c=0.0;
d = parseFloat(form1.op4.value);
if (isNaN(d))
d=0.0;
document.getElementById('top').value = top;
form1.top.value = a + b + c + d;
}
</script>
<body>
<form id="form1" name="form1" method="post" action="" onSubmit="return checkForm(this)">
  <table width="478" border="2" align="left" bordercolor="blue" style="border-collapse: collapse; border-style:dashed">
    <tr>
      <td><table width="465" border="0">
          <tr>
            <td width="154" nowrap="nowrap" class="style10"><strong>Pendidikan Terakhir </strong></td>
            <td width="301"><strong>:</strong>
                <select name="op1" onchange="dik()" id="op1">
                  <option value="" selected="selected">.::Pilih::.</option>
                  <option value="SMA-1">SMA</option>
                  <option value="D1-2">D1</option>
                  <option value="D2-3">D2</option>
                  <option value="D3-4">D3</option>
                  <option value="S1-5">S1</option>
                  <option value="S2-6">S2</option>
                  <option value="S3-7">S3</option>
                </select>
              <label> <strong>Pend : </strong>
                  <input name="pendidikan" id="pendidikan" type="text" value="lulusan" size="5" maxlength="5" />
                <strong>Poin : </strong>
                <input name="poin" type="text" id="poin" size="5" maxlength="5" readonly="readonly" />
              </label></td>
          </tr>
          <tr>
            <td nowrap="nowrap" class="style10">Fak/ Jurusan </td>
            <td><label><strong>:</strong>
                  <input name="jur" type="text" id="jur" />
              </label>
                <strong>=&gt;</strong>
                <select name="op2" onclick="didik()" id="op2">
                  <option value="" selected="selected">.::Pilih::.</option>
                  <option value="1">1</option>
                  <option value="2">2</option>
                  <option value="3">3</option>
                  <option value="4">4</option>
                  <option value="5">5</option>
                  <option value="6">6</option>
                  <option value="7">7</option>
              </select></td>
          </tr>
          <tr>
            <td nowrap="nowrap" class="style10"><strong>Lulusan Dari</strong></td>
            <td><label><strong>:</strong>
                  <select name="op3" onclick="didik()" id="op3">
                    <option value="" selected="selected">.::Pilih::.</option>
                    <option value="7">Negeri Akreditasi A</option>
                    <option value="6">Negeri Akreditasi B</option>
                    <option value="5">Negeri Akreditasi C</option>
                    <option value="4">Swasta Akreditasi A</option>
                    <option value="3">Swasta Akreditasi B</option>
                    <option value="2">Swasta Akreditasi C</option>
                    <option value="1">Swasta Non Akreditasi</option>
                  </select>
            </label></td>
          </tr>
          <tr>
            <td nowrap="nowrap" class="style10"><strong>Lulus Tahun </strong></td>
            <td><strong>:</strong>
                <select name="op4" onclick="didik()" id="op4">
                  <option value="" selected="selected">.::Pilih::.</option>
                  <option value="7" id="op3">Tahun Ini</option>
                  <option value="6" id="op3">Tahun Lalu</option>
                  <option value="5" id="op3">2 Tahun Lalu</option>
                  <option value="4" id="op3">3 Tahun Lalu</option>
                  <option value="3" id="op3">4 Tahun Lalu</option>
                  <option value="2" id="op3">5 Tahun Lalu</option>
                  <option value="1" id="op3">Lebih Dari 5 Tahun Lalu</option>
              </select></td>
          </tr>
          <tr>
            <td><strong>Asal Pendidikan </strong></td>
            <td><label> <strong>: </strong>
                  <input name="asal" type="text" id="asal" />
            </label></td>
          </tr>
          <tr>
            <td>&nbsp;</td>
            <td><strong><span class="style18"><span class="style8 style2">Total </span>: </span>
                  <input name="top" type="text" id="top" size="4" maxlength="4" value="" readonly="readonly"/>
            </strong></td>
          </tr>
      </table></td>
    </tr>
  </table>
</form>
</body>
</html>​​
0
Loading...
ulfa · Aug 14, 2012 · 0 Suka · 0 Tidak Suka
matur thank U sanget mas ellyx :) jadi + semangat mempelajari php sepuluh jempol buat mas ellyx... ;)