使用PHP + HTML计算复选框

时间:2012-12-05 13:01:23

标签: php html

我正在为医院做一个系统,目前正在进行的模块是患者账单的交易/计算。我在一个带有复选框的页面中列出了所有费用。如何在提交时计算这些?

<?php
$mysql_hostname = "localhost";
$mysql_user = "root";
$mysql_password = "";
$mysql_database = "hmis";
$bd = mysql_connect($mysql_hostname, $mysql_user, $mysql_password) or die("Could not connect database");
mysql_select_db($mysql_database, $bd) or die("Could not select database");

        $query = "SELECT * FROM charges";

    $result = mysql_query($query);

    echo "<font face=verdana><br><center><h2>ER CHARGES</h2></center>";

    if(mysql_num_rows($result) > 0){
        echo '<br><br><center><table border="1" cellspacing="3">
        <tr>
            <th>Pro.#</th>
            <th>Procedure</th>
            <th>Price</th>
            <th></th>
        </tr>
        ';





        while($row = mysql_fetch_array($result)){
            echo '
            <tr>
                <td>'.$row[0].'</td>
                <td>'.$row[1].'</td>
                <td>'.$row[2].'</td>
                <td><input type="checkbox"></td>
            </tr>
            ';
        }
        echo '</table>';
    }else{
        echo '<p style="color: red">Not found!</p>';
    }


    // ULTRASOUND

        $query2 = "SELECT * FROM ultrasound";

    $result2 = mysql_query($query2);


    echo "<br><center><h2>ULTRASOUND CHARGES</h2></center>";

        if(mysql_num_rows($result2) > 0){
        echo '<br><br><center><font face=verdana><table border="1" cellspacing="3">
        <tr>
            <th>Pro.#</th>
            <th>Procedure</th>
            <th>Price</th>
            <th></th>
        </tr>
        ';





        while($row = mysql_fetch_array($result2)){
            echo '
            <tr>
                <td>'.$row[0].'</td>
                <td>'.$row[1].'</td>
                <td>'.$row[2].'</td>
                <td><input type="checkbox"></td>
            </tr>
            ';
        }
        echo '</table>';
    }else{
        echo '<p style="color: red">Not found!</p>';
    }


    // confinement

        $query3 = "SELECT * FROM confinement";

    $result3 = mysql_query($query3);


    echo "<br><center><h2>CONFINEMENT CHARGES</h2></center>";

        if(mysql_num_rows($result3) > 0){
        echo '<br><br><center><font face=verdana><table border="1" cellspacing="3">
        <tr>
            <th>Pro.#</th>
            <th>Procedure</th>
            <th>Price</th>
            <th></th>
        </tr>
        ';





        while($row = mysql_fetch_array($result3)){
            echo '
            <tr>
                <td>'.$row[0].'</td>
                <td>'.$row[1].'</td>
                <td>'.$row[2].'</td>
                <td><input type="checkbox"></td>
            </tr>
            ';
        }
        echo '</table>';
    }else{
        echo '<p style="color: red">Not found!</p>';

    }
    echo '<br><input type="submit" name="submit">';

?>

我在想每个复选框都有值,但我觉得它不起作用。

0 个答案:

没有答案