Một số hàm tính toán

Thảo luận trong 'PHP' bắt đầu bởi AmGian, 21 Tháng tám 2009.

  1. Offline

    AmGian

    • Thành viên sáng lập

    Số bài viết:
    392
    Đã được thích:
    231
    Điểm thành tích:
    220
    1. Tính kết quả học tập:
    <!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=utf-8" />
    <title>Ket qua hoc tap</title>
    <style type="text/css">
    <!--
    .style1 {
    color: #FFFFFF;
    font-weight: bold;
    font-size: 24px;
    }
    .style2 {color: #FFFFFF}
    -->
    </style>
    </head>

    <body>
    <?php
    if(isset($_POST["dhk1"]) && isset($_POST["dhk2"]))
    {
    $dhk1 = $_POST["dhk1"];
    $dhk2 = $_POST["dhk2"];
    $dtb = ($dhk1 + $dhk2*2)/3;
    $dtb = round($dtb,2);
    if($dtb >= 5)
    $kqht = "Được Lên Lớp";
    else
    $kqht = "Bạn Phải Học Lại";
    if($dtb >=8)
    $xlhl = "Giỏi";
    elseif($dtb < 8 && $dtb >= 6.5)
    $xlhl = "Khá";
    elseif($dtb < 6.5 && $dtb >=5)
    $xlhl = "Trung Bình";
    elseif($dtb < 5 && $dtb >=3)
    $xlhl = "Yếu";
    else
    $xlhl = "Kém";
    }
    ?>
    <form id="form1" name="form1" method="post" action="ket_qua_hoc_tap.php">
    <table width="365" border="1" align="center" cellpadding="2" cellspacing="2" bgcolor="#FFFFFF">
    <tr>
    <th colspan="2" bgcolor="#000066" scope="col"><span class="style1">KẾT QUẢ HỌC TẬP </span></th>
    </tr>
    <tr>
    <th width="174" bgcolor="#666666" scope="row"><span class="style2">Điểm HK I </span></th>
    <td width="171" bgcolor="#666666"><label>
    <input name="dhk1" type="text" id="dhk1" value="<?php echo $_POST["dhk1"];?>" />
    </label></td>
    </tr>
    <tr>
    <th bgcolor="#666666" scope="row"><span class="style2">Điểm HK II </span></th>
    <td bgcolor="#666666"><label>
    <input name="dhk2" type="text" id="dhk2" value="<?php echo $_POST["dhk2"];?>" />
    </label></td>
    </tr>
    <tr>
    <th bgcolor="#666666" scope="row"><span class="style2">Điểm Trung Bình </span></th>
    <td bgcolor="#666666"><label>
    <input name="dtb" type="text" id="dtb" value="<?php echo $dtb;?>" readonly="true" style="background-color:#CCFFFF" />
    </label></td>
    </tr>
    <tr>
    <th bgcolor="#666666" scope="row"><span class="style2">Kết Quả Học Tập </span></th>
    <td bgcolor="#666666"><label>
    <input name="kqht" type="text" id="kqht" value="<?php echo $kqht;?>" readonly="true" style="background-color:#CCFFFF" />
    </label></td>
    </tr>
    <tr>
    <th bgcolor="#666666" scope="row"><span class="style2">Xếp Loại Học Lực </span></th>
    <td bgcolor="#666666"><label>
    <input name="xlhl" type="text" id="xlhl" value="<?php echo $xlhl;?>" readonly="true" style="background-color:#CCFFFF" />
    </label></td>
    </tr>
    <tr>
    <th colspan="2" bgcolor="#003366" scope="row"><label>
    <input type="submit" name="Submit" value="Thực Hiện" />
    </label></th>
    </tr>
    </table>
    </form>
    </body>
    </html>

    2. Diện tích hình chữ nhật:
    <!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=utf-8" />
    <title>dien tich hinh chu nhat</title>
    <style type="text/css">
    <!--
    .style2 {color: #FFFFFF}
    -->
    </style>
    </head>

    <body>
    <?php
    $dai = $_POST["dai"];
    $rong = $_POST["rong"];
    $dt = $dai * $rong;
    ?>
    <form id="form1" name="form1" method="post" action="">
    <table width="339" border="1" align="center" cellpadding="2" cellspacing="2" bgcolor="#CCFF33">
    <tr>
    <th colspan="2" bgcolor="#999900" scope="col"><span class="style2">DIỆN TÍCH HÌNH CHỮ NHẬT </span></th>
    </tr>
    <tr>
    <th width="146" scope="row">Chiều Dài </th>
    <td width="173"><label>
    <input name="dai" type="text" id="dai" value="<?php echo $_POST["dai"];?>" size="20" />
    </label></td>
    </tr>
    <tr>
    <th scope="row">Chiều Rộng </th>
    <td><label>
    <input name="rong" type="text" id="rong" value="<?php echo $_POST["rong"];?>" size="20" />
    </label></td>
    </tr>
    <tr>
    <th scope="row">Diện Tích </th>
    <td><label>
    <input name="dt" type="text" id="dt" value="<?php echo $dt;?>" size="20" readonly="true" style="background-color:#66CCCC"/>
    </label></td>
    </tr>
    <tr>
    <th colspan="2" align="center" scope="row"><label>
    <input type="submit" name="Submit" value="Tính" />
    </label></th>
    </tr>
    </table>
    </form>
    </body>
    </html>

    3. Diện tích và chu vi hình tròn:

    <!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=utf-8" />
    <title>Dien tich va Chu vi hinh tron</title>
    <style type="text/css">
    <!--
    .style3 {
    color: #0000CC;
    font-weight: bold;
    font-size: 18px;
    }
    -->
    </style>
    </head>

    <body>
    <?php
    if(isset($_POST["bankinh"]))
    {
    $bankinh = $_POST["bankinh"];
    define("PI",3.14);
    $dientich = PI * pow($bankinh,2);
    $chuvi = 2 * PI * $bankinh;
    }
    ?>
    <form id="form1" name="form1" method="post" action="">
    <table width="339" border="1" align="center" cellpadding="2" cellspacing="2" bgcolor="#99FF66">
    <tr>
    <th colspan="2" bgcolor="#99CC00" scope="col"><span class="style3">DIỆN TÍCH VÀ CHU VI HÌNH TRÒN </span></th>
    </tr>
    <tr>
    <th width="127" scope="row">Bán Kính </th>
    <td width="192"><label>
    <input name="bankinh" type="text" id="bankinh" value="<?php echo $_POST["bankinh"];?>" size="20" />
    </label></td>
    </tr>
    <tr>
    <th scope="row">Diện Tích </th>
    <td><label>
    <input name="dientich" type="text" id="dientich" value="<?php echo $dientich;?>" size="20" readonly="true" style="background-color:#CCFFCC" />
    </label></td>
    </tr>
    <tr>
    <th scope="row">Chu Vi </th>
    <td><label>
    <input name="chuvi" type="text" id="chuvi" value="<?php echo $chuvi;?>" size="20" readonly="true" style="background-color:#CCFFCC" />
    </label></td>
    </tr>
    <tr>
    <th colspan="2" scope="row"><label>
    <input type="submit" name="Submit" value="Tính" />
    </label></th>
    </tr>
    </table>
    </form>
    </body>
    </html>

    3. Thanh toán tiền điện:
    <!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=utf-8" />
    <title>Thanh toan tien dien</title><style type="text/css">
    <!--
    .style1 {font-size: 18px}
    -->
    </style></head>

    <body>
    <?php
    if(isset($_POST["tenchuho"]) && isset($_POST["chisocu"]) && isset($_POST["chisomoi"]))
    {
    $chisocu = $_POST["chisocu"];
    $chisomoi = $_POST["chisomoi"];
    $dongia = $_POST["dongia"];
    $sttt = ($chisomoi - $chisocu) * $dongia;
    }
    ?>
    <form id="form1" name="form1" method="post" action="thanh_toan_tien_dien.php">
    <table width="416" border="1" align="center" cellpadding="2" cellspacing="2" bgcolor="#CCFF99">
    <tr>
    <th colspan="2" bgcolor="#99CC33" scope="col"><strong><span class="style1">THANH TOÁN TIỀN ĐIỆN </span></strong></th>
    </tr>
    <tr>
    <th width="162" scope="row">Tên chủ hộ </th>
    <td width="234"><label>
    <input name="tenchuho" type="text" id="tenchuho" value="<?php echo $_POST["tenchuho"];?>" />
    </label></td>
    </tr>
    <tr>
    <th scope="row">Chỉ số cũ </th>
    <td><label>
    <input name="chisocu" type="text" id="chisocu" value="<?php echo $_POST["chisocu"];?>" />
    (Kw)</label></td>
    </tr>
    <tr>
    <th scope="row">Chỉ số mới </th>
    <td><label>
    <input name="chisomoi" type="text" id="chisomoi" value="<?php echo $_POST["chisomoi"];?>" />
    (Kw)</label></td>
    </tr>
    <tr>
    <th scope="row">Đơn giá </th>
    <td><label>
    <input name="dongia" type="text" id="dongia" value="2000" />
    (VND)</label></td>
    </tr>
    <tr>
    <th scope="row">Số tiền thanh toán </th>
    <td><label>
    <input name="sttt" type="text" id="sttt" value="<?php echo $sttt;?>" readonly="true" style="background-color:#99CC00" />
    (VND)</label></td>
    </tr>
    <tr>
    <th colspan="2" bgcolor="#99CC00" scope="row"><label>
    <input type="submit" name="Submit" value="TÍNH" />
    </label></th>
    </tr>
    </table>
    </form>
    </body>
    </html>

    4. Tìm số lớn hơn:
    <!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=utf-8" />
    <title>Tim so lon hon</title>
    </head>

    <body>
    <?php
    if(isset($_POST["so_a"]) && isset($_POST["so_b"]))
    {
    $so_a = $_POST["so_a"];
    $so_b = $_POST["so_b"];
    if($so_a > $so_b)
    $so_lon_hon = $so_a;
    else
    $so_lon_hon = $so_b;
    }
    ?>
    <form id="form1" name="form1" method="post" action="tim_so_lon_hon.php">
    <table width="303" border="1" align="center" cellpadding="2" cellspacing="2" bgcolor="#99FF66">
    <tr>
    <th colspan="2" bgcolor="#99CC00" scope="col">TÌM SỐ LỚN HƠN </th>
    </tr>
    <tr>
    <th width="107" scope="row">Số A </th>
    <td width="176"><label>
    <input name="so_a" type="text" id="so_a" value="<?php echo $_POST["so_a"];?>" />
    </label></td>
    </tr>
    <tr>
    <th scope="row">Số B </th>
    <td><label>
    <input name="so_b" type="text" id="so_b" value="<?php echo $_POST["so_b"];?>" />
    </label></td>
    </tr>
    <tr>
    <th scope="row">Số lớn hơn </th>
    <td><!-- -->
    <label>
    <input name="so_lon_hon" type="text" id="so_lon_hon" value="<?php echo $so_lon_hon;?>" readonly="true" style="background-color:#99CC00" />
    </label></td>
    </tr>
    <tr>
    <th colspan="2" bgcolor="#99CC00" scope="row"><label>
    <input type="submit" name="Submit" value="TÍNH" />
    </label></th>
    </tr>
    </table>
    </form>
    </body>
    </html>

    5. Tính kết quả thi đại học:
    (cái này mình tính có thêm môn thi năng khiếu mà không biết cách tính như thế có đúng không, nếu có ji các bạn thông báo cho mình nha. THANK)
    <!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=utf-8" />
    <title>diem thi dai hoc</title>
    </head>

    <body>
    <?php
    if(isset($_POST["mon1"]) && isset($_POST["mon2"]) && isset($_POST["mon3"]) && isset($_POST["nangkhieu"]) && isset($_POST["diemchuan"]))
    {
    $mon1 = $_POST["mon1"];
    $mon2 = $_POST["mon2"];
    $mon3 = $_POST["mon3"];
    $nangkhieu = $_POST["nangkhieu"];
    $diemchuan = $_POST["diemchuan"];
    $tongdiem = ($mon1 + $mon2 + $mon3) +($nangkhieu * 2);
    if($tongdiem >= $diemchuan && $mon1 >0 && $mon2 > 0 && $mon3 >0 && $nangkhieu > 0)
    $ketqua = "Bạn Đã Đậu";
    else
    $ketqua = "Bạn Đã Rớt";
    }
    ?>
    <form id="form1" name="form1" method="post" action="diem_thi_dai_hoc.php">
    <table width="320" border="1" align="center" cellpadding="2" cellspacing="2">
    <tr>
    <th colspan="2" bgcolor="#FF99FF" scope="col">ĐIỂM THI ĐẠI HỌC </th>
    </tr>
    <tr>
    <th width="118" bgcolor="#FFCCFF" scope="row">Môn I </th>
    <td width="182" bgcolor="#FFCCFF"><label>
    <input name="mon1" type="text" id="mon1" value="<?php echo $_POST["mon1"];?>" />
    </label></td>
    </tr>
    <tr>
    <th bgcolor="#FFCCFF" scope="row">Môn II </th>
    <td bgcolor="#FFCCFF"><label>
    <input name="mon2" type="text" id="mon2" value="<?php echo $_POST["mon2"];?>" />
    </label></td>
    </tr>
    <tr>
    <th bgcolor="#FFCCFF" scope="row">Môn III </th>
    <td bgcolor="#FFCCFF"><label>
    <input name="mon3" type="text" id="mon3" value="<?php echo $_POST["mon3"];?>" />
    </label></td>
    </tr>
    <tr>
    <th bgcolor="#FFCCFF" scope="row">Năng Khiếu </th>
    <td bgcolor="#FFCCFF"><label>
    <input name="nangkhieu" type="text" id="nangkhieu" value="<?php echo $_POST["nangkhieu"];?>" />
    </label></td>
    </tr>
    <tr>
    <th bgcolor="#FFCCFF" scope="row">Điểm Chuẩn </th>
    <td bgcolor="#FFCCFF"><label>
    <input name="diemchuan" type="text" id="diemchuan" value="<?php echo $_POST["diemchuan"];?>" />
    </label></td>
    </tr>
    <tr>
    <th bgcolor="#FFCCFF" scope="row">Tổng Điểm </th>
    <td bgcolor="#FFCCFF"><label>
    <input name="tongdiem" type="text" id="tongdiem" value="<?php echo $tongdiem;?>" readonly="true" />
    </label></td>
    </tr>
    <tr>
    <th bgcolor="#FFCCFF" scope="row">Kết Quả </th>
    <td bgcolor="#FFCCFF"><label>
    <input name="ketqua" type="text" id="ketqua" value="<?php echo $ketqua;?>" readonly="true" style="background-color:#FF99FF" />
    </label></td>
    </tr>
    <tr>
    <th colspan="2" bgcolor="#FF99FF" scope="row"><label>
    <input type="submit" name="Submit" value="Thực Hiện" />
    </label></th>
    </tr>
    </table>
    </form>
    </body>
    </html>
    :yyc21:
    Seshoumaru thích bài này.
  2. Offline

    Seshoumaru

    • Friends

    Số bài viết:
    379
    Đã được thích:
    180
    Điểm thành tích:
    0
    đang cần mấy cái này, năm sau phải học lại môn này mới ác chứ

Chia sẻ trang này

Advertising: Linux system admin | nukeviet | nukeviet 4 | Upload ảnh miễn phí