tkw-sinhvien

<center>DIEM TONG KET<br /><br />

<?php

    $db = mysql_connect("localhost","root","123456") or die ("Khong the ket noi toi CSDL"); /* Ket noi toi CSDL */

    mysql_select_db("sinhvien",$db);

    if (isset($_POST[hoten]) && $_POST[hoten] != null)  /* Tao cau truy van SQL de cap nhat du lieu */

    {

        mysql_query("UPDATE dssinhvien SET hoten='$_POST[hoten]', lop='$_POST[lop]', diemchuyencan='$_POST[diemchuyencan]', diemthuchanh='$_POST[diemthuchanh]', diemthi='$_POST[diemthi]' WHERE msv='$_GET[msv]'");

    }

    if (isset($_GET['msv']) && $_GET[delete] == true)    /* Dieu kien de xoa du lieu */

    {

        $sql = "DELETE FROM dssinhvien WHERE msv='$_GET[msv]'";  /* Tao cau truy van SQL de xoa du lieu */

        $query = mysql_query($sql);    

    }

    $sql = "SELECT * FROM dssinhvien"; /* Tao cau truy van SQL de lay du lieu tu CSDL */

    $query = mysql_query($sql); 

    if (mysql_num_rows($query) == 0)

        echo "Chua co du lieu !";

        else

        {   /* Bat dau tao bang de xuat du lieu */

            echo "<table border=1>";

            echo "<tr><th>HoTen</th>";

            echo "<th>Lop</th>";

            echo "<th>Diem Chuyen Can</th>";

            echo "<th>Diem Thuc Hanh</th>";

            echo "<th>Diem Thi</th>";

            echo "<th>Diem Tong Ket</th>";

            echo "<th>Thao Tac</th></tr>";

            /* Tao vong lap xuat du lieu */

            while($list = mysql_fetch_array($query))

            {

                $diemtongket=$list[diemchuyencan]*0.1+$list[diemthuchanh]*0.3+$list[diemthi]*0.6;

                echo "<tr><td>".$list[hoten]."</td>";          

                echo "<td align=center>".$list[lop]."</td>";

                echo "<td align=center>".$list[diemchuyencan]."</td>";

                echo "<td align=center>".$list[diemthuchanh]."</td>";

                echo "<td align=center>".$list[diemthi]."</td>";

                echo "<td align=center>".$diemtongket."</td>";

                echo "<td align=center><a href='sinhvien.php?msv=".$list[msv]."'>Sua</a> / ";

                echo "<a href='sinhvien.php?msv=".$list[msv]."&delete=true'>Xoa</a></td></tr>";

            }

            echo"</table><br />";

        }

    if (isset($_GET['msv']))

    {

        $sql = "SELECT * FROM dssinhvien WHERE msv='$_GET[msv]'";  /* Tao cau truy van de xuat du lieu ra khung nhap khi an Sua */

        $query = mysql_query($sql);

        $row = mysql_fetch_array ($query);       

    }

?>

<form>

    <table>

        <tr>

            <td>Ho ten: </td><td><input /></td>

        </tr>

        <tr>

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

        </tr>

        <tr>

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

        </tr>

        <tr>

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

        </tr>

        <tr>

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

        </tr>

        <tr>

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

        </tr>

    </table>

</form>

</center>

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

Tags: