tkw-sua POST

<? ob_start(); ?>

<html>

<body>

 <?php

 //Ket noi CSDL

 $link = mysql_connect("localhost","root","123456") or die("Khong ket noi duoc CSDL");

 mysql_select_db("dssinhvien",$link) or die('Khong chon duoc CSDL');

 ?>

 <?php

  if($_POST['them']) {

   mysql_query("INSERT INTO ".danhsach." SET

    hoten='".$_POST['hoten']."', lop='".$_POST['lop']."', diemchuyencan='".$_POST['diemchuyencan']."',

    diemthuchanh='".$_POST['diemthuchanh']."', diemthi='".$_POST['diemthi']."'");

  }

  if($_POST['sua']) {

    mysql_query("UPDATE ".danhsach." SET

    hoten='".$_POST['hoten']."', lop='".$_POST['lop']."', diemchuyencan='".$_POST['diemchuyencan']."',

    diemthuchanh='".$_POST['diemthuchanh']."', diemthi='".$_POST['diemthi']."'

    WHERE stt='".$_GET['sua']."'");

     header("Location: lam.php");

    }

    if($_GET['xoa']!='') {

    mysql_query("DELETE FROM ".danhsach." WHERE stt='".$_GET['xoa']."' limit 1");

     header("Location: lam.php");

    }

 ?>

 <p> Tong ket sinh vien khoa TMDT </p>

 <table>

  <tr>

   <td> Ho va ten </td>

   <td> Lop </td>

   <td> Diem chuyen can </td>

   <td> Diem thuc hanh </td>

   <td> Diem thi </td>

   <td> Diem tong ket </td>

   <td> Thao tac </td>

  </tr>

  <tr>

   <?

   $sqlstr = mysql_query("SELECT * FROM ".danhsach." order by stt");

   if(mysql_num_rows($sqlstr)>0) {

    while($row=mysql_fetch_array($sqlstr)) {

   ?>

   <td> <?=$row['hoten']?></td>

  <td> <?=$row['lop']?></td>

  <td> <?=$row['diemchuyencan']?></td>

  <td> <?=$row['diemthuchanh']?></td>

  <td> <?=$row['diemthi']?></td>

  <td>

  <? //Tinh diem tong ket:

  $a = $row['diemchuyencan'] * 0.1 + $row['diemthuchanh']*0.3 + $row['diemthi']*0.6;

  echo $a;

  ?>

  </td>

  <td>

   <a>Sua</a>/<a>Xoa</a>

  </td>

  </tr>

   <? } } ?>

</table>

<? if($_GET['sua']=='') {?>

<br />

<form>

 <table>

<tr>

<tr><td> Ho va ten: </td>

<td> <input></td></tr>

 <tr><td>Lop: <td><input></td></tr>

<tr> <td>Diem chuyen can: <td><input></td></tr>

 <tr><td>Diem thuc hanh: <td><input></td></tr>

 <tr><td>Diem thi: <td><input></td></tr>

 <tr><td><input></td></tr>

 </form>

<? } ?>

<? if($_GET['sua']!='') {?>

<?

 $sqlstr=mysql_query("SELECT * FROM ".danhsach." WHERE stt='".$_GET['sua']."' ");

 if (mysql_num_rows($sqlstr)>0) {

  while ($row=mysql_fetch_array($sqlstr)) { ?>

  <br />

 <form>

 <table>

<tr>

<tr><td> Ho va ten: </td>

<td> <input></td></tr>

 <tr><td>Lop: <td><input></td></tr>

<tr> <td>Diem chuyen can: <td><input></td></tr>

 <tr><td>Diem thuc hanh: <td><input></td></tr>

 <tr><td>Diem thi: <td><input></td></tr>

 <tr><td><input></td></tr>

 </form>

<? } } } ?>

</body>

</html>

Bạn đang đọc truyện trên: AzTruyen.Top

Tags: