Rubric Generator的调整

时间:2015-08-18 07:07:16

标签: php sql html-table

我已经创建了一个用于标记12行的表/标题,但是如果用户填写或使用的内容少于给定的内容,该怎么办? 那么我需要对我的php代码进行哪些更改以允许它,因为我的代码要求用户输入所有12行?

这是PHP代码:

<?php
mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db("abc") or die(mysql_error());


$tablename = $_POST['title'];
$cat1 = $_POST['title_1'];
$cat2 = $_POST['title_2'];
$cat3 = $_POST['title_3'];
$cat4 = $_POST['title_4'];
$cat5 = $_POST['title_5'];
$cat6 = $_POST['title_6'];
$cat7 = $_POST['title_7'];
$cat8 = $_POST['title_8'];
$cat9 = $_POST['title_9'];
$cat10 = $_POST['title_10'];
$cat11 = $_POST['title_11'];
$cat12 = $_POST['title_12'];
$mark1 = $_POST['title_1_1'];
$mark2 = $_POST['title_1_2'];
$mark3 = $_POST['title_1_3'];
$mark4 = $_POST['title_1_4'];
$mark5 = $_POST['title_1_5'];
$mark6 = $_POST['title_1_6'];
$mark7 = $_POST['title_1_7'];
$mark8 = $_POST['title_1_8'];
$mark9 = $_POST['title_1_9'];
$mark10 = $_POST['title_1_10'];
$mark11 = $_POST['title_1_11'];
$mark12 = $_POST['title_1_12'];

mysql_query("CREATE TABLE $tablename (
id INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY, 
$cat1 INT($mark1), $cat2 INT($mark2), $cat3 INT($mark3), $cat4 INT($mark4), $cat5 INT($mark5), $cat6 INT($mark6),
$cat7 INT($mark7), $cat8 INT($mark8), $cat9 INT($mark9), $cat10 INT($mark10), $cat11 INT($mark11), $cat12 INT($mark12),
Total INT (200))")
 or die(mysql_error());  


header("Location: index2.php");

?>

这是界面:

<!DOCTYPE html>

<html>
    <head>
        <title>Rubric</title>

    </head>
    <body>
    <form action="rubric.php" method="post" enctype="multipart/form-data" name="form1" id="formWrap"> 
    <center>
      <table>
        <tr>
            <td>
                <h2>Rubruc's Title:<h2>
            </td>

            <td>
                <input type="text" name="title" >
            </td>
        </tr>
       </table>

       <table>     
        <tr>
            <td>
            Please input text before numbers (Example: TPR2211).
            </td>
        </tr>
        </table>

      </br>
        <table border = "1" cellpadding = "2" cellspacing = "0">
                <tr>
                    <td valign = "center" align = "center" bgcolor = "#fffff7">
                        <div id = "div_content_bold">
                            Category
                        </div>
                    </td>
                    <td bgcolor = "#fffff7">
                        &nbsp;
                    </td>

                    <td valign = "center" align = "center" bgcolor = "#fffff7">
                        <div id = "div_content_bold">
                            Max. Marks
                        </div>
                    </td>
                    <td bgcolor = "#fffff7">
                        &nbsp;
                    </td>

                </tr>

                <tr>
                    <td valign = "top" width = "200">
                        <br>

                        <div id = "div_small">
                            <table border = 0>
                                <tr>
                                    <td valign = "top">
                                        <div id = "div_small">

                                        Input your category:<br>
                                        <br>
    <input name = "title_1" type = "text" value = "" class = "input"
         size = 20 maxlength = 100 class="textPage">
                                        <br> <br>
                                        Add your max. marks in the rubric text boxes to the right:<br>
                                    </td>
                                </tr>
                            </table>

                        </div>
                    </td>
                    <td bgcolor = "#C2C2C2">
                        &nbsp;
                    </td>                   

                    <td valign = "top">
                        <br>
                        <div id = "div_content_bold">
                        <br> <br>
                            <input name = "title_1_1" type = "text" value = "" class = "input"
                              size = 20 maxlength = 200 class="textPage">
                        </div>

                        <br>
                    </td>
                    <td bgcolor = "#C2C2C2">
                        &nbsp;
                    </td>

                </tr>

                <tr>
                    <td valign = "top" width = "200">
                        <br>
                        <div id = "div_small">
                            <table border = 0>
                                <tr>
                                    <td valign = "top">
                                        <div id = "div_small">

                                        Input your category:<br>
                                        <br>
    <input name = "title_2" type = "text" value = "" class = "input"
         size = 20 maxlength = 100 class="textPage">
                                        <br> <br>
                                    Add your max. marks in the rubric text boxes to the right:<br>
                                    </td>
                                </tr>
                            </table>

                        </div>
                    </td>
                    <td bgcolor = "#C2C2C2">
                        &nbsp;
                    </td>                   

                    <td valign = "top">
                        <br>
                        <div id = "div_content_bold">
                            <br> <br>
                            <input name = "title_1_2" type = "text" value = "" class = "input"
                              size = 20 maxlength = 200 class="textPage">
                        </div>
                        <br>
                    </td>
                    <td bgcolor = "#C2C2C2">
                        &nbsp;
                    </td>
                </tr>

                <tr>
                    <td valign = "top" width = "200">
                        <br>
                        <div id = "div_small">
                            <table border = 0>
                                <tr>
                                    <td valign = "top">
                                        <div id = "div_small">

                                        Input your category:<br>
                                        <br>
    <input name = "title_3" type = "text" value = "" class = "input"
         size = 20 maxlength = 100 class="textPage">
                                        <br> <br>
                                        Add your max. marks in the rubric text boxes to the right:<br>
                                    </td>
                                </tr>
                            </table>

                        </div>
                    </td>
                    <td bgcolor = "#C2C2C2">
                        &nbsp;
                    </td>                   

                    <td valign = "top">
                        <br>
                        <div id = "div_content_bold">
                            <br> <br>
                            <input name = "title_1_3" type = "text" value = "" class = "input"
                              size = 20 maxlength = 200 class="textPage">
                        </div>

                        <br>
                    </td>
                    <td bgcolor = "#C2C2C2">
                        &nbsp;
                    </td>
                </tr>

                <tr>
                    <td valign = "top" width = "200">
                        <br>
                        <div id = "div_small">
                            <table border = 0>
                                <tr>
                                    <td valign = "top">
                                        <div id = "div_small">

                                        Input your category:<br>
                                        <br>
    <input name = "title_4" type = "text" value = "" class = "input"
         size = 20 maxlength = 100 class="textPage">
                                        <br> <br>
                                        Add your max. marks in the rubric text boxes to the right:<br>
                                    </td>
                                </tr>
                            </table>

                        </div>
                    </td>
                    <td bgcolor = "#C2C2C2">
                        &nbsp;
                    </td>                   

                    <td valign = "top">
                        <br>
                        <div id = "div_content_bold">
                            <br> <br>
                            <input name = "title_1_4" type = "text" value = "" class = "input"
                              size = 20 maxlength = 200 class="textPage">
                        </div>

                        <br>
                    </td>
                    <td bgcolor = "#C2C2C2">
                        &nbsp;
                    </td>
                </tr>

                <tr>
                    <td valign = "top" width = "200">
                        <br>
                        <div id = "div_small">
                            <table border = 0>
                                <tr>
                                    <td valign = "top">
                                        <div id = "div_small">

                                        Input your category:<br>
                                        <br>
    <input name = "title_5" type = "text" value = "" class = "input"
         size = 20 maxlength = 100 class="textPage">
                                        <br> <br>
                                        Add your max. marks in the rubric text boxes to the right:<br>
                                    </td>
                                </tr>
                            </table>

                        </div>
                    </td>
                    <td bgcolor = "#C2C2C2">
                        &nbsp;
                    </td>                   

                    <td valign = "top">
                        <br>
                        <div id = "div_content_bold">
                            <br> <br>
                            <input name = "title_1_5" type = "text" value = "" class = "input"
                              size = 20 maxlength = 200 class="textPage">
                        </div>

                        <br>
                    </td>
                    <td bgcolor = "#C2C2C2">
                        &nbsp;
                    </td>
                </tr>

                <tr>
                    <td valign = "top" width = "200">
                        <br>
                        <div id = "div_small">
                            <table border = 0>
                                <tr>
                                    <td valign = "top">
                                        <div id = "div_small">

                                        Input your category:<br>
                                        <br>
    <input name = "title_6" type = "text" value = "" class = "input"
         size = 20 maxlength = 100 class="textPage">
                                        <br> <br>
                                        Add your max. marks in the rubric text boxes to the right:<br>
                                    </td>
                                </tr>
                            </table>

                        </div>
                    </td>
                    <td bgcolor = "#C2C2C2">
                        &nbsp;
                    </td>                   

                    <td valign = "top">
                        <br>
                        <div id = "div_content_bold">
                            <br> <br>
                            <input name = "title_1_6" type = "text" value = "" class = "input"
                              size = 20 maxlength = 200 class="textPage">
                        </div>

                        <br>
                    </td>
                    <td bgcolor = "#C2C2C2">
                        &nbsp;
                    </td>
                </tr>

                <tr>
                    <td valign = "top" width = "200">
                        <br>
                        <div id = "div_small">
                            <table border = 0>
                                <tr>
                                    <td valign = "top">
                                        <div id = "div_small">

                                        Input your category:<br>
                                        <br>
    <input name = "title_7" type = "text" value = "" class = "input"
         size = 20 maxlength = 100 class="textPage">
                                        <br> <br>
                                        Add your max. marks in the rubric text boxes to the right:<br>
                                    </td>
                                </tr>
                            </table>

                        </div>
                    </td>
                    <td bgcolor = "#C2C2C2">
                        &nbsp;
                    </td>                   

                    <td valign = "top">
                        <br>
                        <div id = "div_content_bold">
                            <br> <br>
                            <input name = "title_1_7" type = "text" value = "" class = "input"
                              size = 20 maxlength = 200 class="textPage">
                        </div>

                        <br>
                    </td>
                    <td bgcolor = "#C2C2C2">
                        &nbsp;
                    </td>
                </tr>

                <tr>
                    <td valign = "top" width = "200">
                        <br>
                        <div id = "div_small">
                            <table border = 0>
                                <tr>
                                    <td valign = "top">
                                        <div id = "div_small">

                                        Input your category:<br>
                                        <br>
    <input name = "title_8" type = "text" value = "" class = "input"
         size = 20 maxlength = 100 class="textPage">
                                        <br> <br>
                                        Add your max. marks in the rubric text boxes to the right:<br>
                                    </td>
                                </tr>
                            </table>

                        </div>
                    </td>
                    <td bgcolor = "#C2C2C2">
                        &nbsp;
                    </td>                   

                    <td valign = "top">
                        <br>
                        <div id = "div_content_bold">
                            <br> <br>
                            <input name = "title_1_8" type = "text" value = "" class = "input"
                              size = 20 maxlength = 200 class="textPage">
                        </div>

                        <br>
                    </td>
                    <td bgcolor = "#C2C2C2">
                        &nbsp;
                    </td>
                </tr>

                <tr>
                    <td valign = "top" width = "200">
                        <br>
                        <div id = "div_small">
                            <table border = 0>
                                <tr>
                                    <td valign = "top">
                                        <div id = "div_small">

                                        Input your category:<br>
                                        <br>
    <input name = "title_9" type = "text" value = "" class = "input"
         size = 20 maxlength = 100 class="textPage">
                                        <br> <br>
                                        Add your max. marks in the rubric text boxes to the right:<br>
                                    </td>
                                </tr>
                            </table>

                        </div>
                    </td>
                    <td bgcolor = "#C2C2C2">
                        &nbsp;
                    </td>                   

                    <td valign = "top">
                        <br>
                        <div id = "div_content_bold">
                            <br> <br>
                            <input name = "title_1_9" type = "text" value = "" class = "input"
                              size = 20 maxlength = 200 class="textPage">
                        </div>

                        <br>
                    </td>
                    <td bgcolor = "#C2C2C2">
                        &nbsp;
                    </td>
                </tr>

                <tr>
                    <td valign = "top" width = "200">
                        <br>
                        <div id = "div_small">
                            <table border = 0>
                                <tr>
                                    <td valign = "top">
                                        <div id = "div_small">

                                        Input your category:<br>
                                        <br>
    <input name = "title_10" type = "text" value = "" class = "input"
         size = 20 maxlength = 100 class="textPage">
                                        <br> <br>
                                        Add your max. marks in the rubric text boxes to the right:<br>
                                    </td>
                                </tr>
                            </table>

                        </div>
                    </td>
                    <td bgcolor = "#C2C2C2">
                        &nbsp;
                    </td>                   

                    <td valign = "top">
                        <br>
                        <div id = "div_content_bold">
                            <br> <br>
                            <input name = "title_1_10" type = "text" value = "" class = "input"
                              size = 20 maxlength = 200 class="textPage">
                        </div>

                        <br>
                    </td>
                    <td bgcolor = "#C2C2C2">
                        &nbsp;
                    </td>
                </tr>

                <tr>
                    <td valign = "top" width = "200">
                        <br>
                        <div id = "div_small">
                            <table border = 0>
                                <tr>
                                    <td valign = "top">
                                        <div id = "div_small">

                                        Input your category:<br>
                                        <br>
    <input name = "title_11" type = "text" value = "" class = "input"
         size = 20 maxlength = 100 class="textPage">
                                        <br> <br>
                                        Add your max. marks in the rubric text boxes to the right:<br>
                                    </td>
                                </tr>
                            </table>

                        </div>
                    </td>
                    <td bgcolor = "#C2C2C2">
                        &nbsp;
                    </td>                   

                    <td valign = "top">
                        <br>
                        <div id = "div_content_bold">
                            <br> <br>
                            <input name = "title_1_11" type = "text" value = "" class = "input"
                              size = 20 maxlength = 200 class="textPage">
                        </div>

                        <br>
                    </td>
                    <td bgcolor = "#C2C2C2">
                        &nbsp;
                    </td>
                </tr>

                <tr>
                    <td valign = "top" width = "200">
                        <br>
                        <div id = "div_small">
                            <table border = 0>
                                <tr>
                                    <td valign = "top">
                                        <div id = "div_small">

                                        Input your category:<br>
                                        <br>
    <input name = "title_12" type = "text" value = "" class = "input"
         size = 20 maxlength = 100 class="textPage">
                                        <br> <br>
                                        Add your max. marks in the rubric text boxes to the right:<br>
                                    </td>
                                </tr>
                            </table>

                        </div>
                    </td>
                    <td bgcolor = "#C2C2C2">
                        &nbsp;
                    </td>                   

                    <td valign = "top">
                        <br>
                        <div id = "div_content_bold">
                            <br> <br>
                            <input name = "title_1_12" type = "text" value = "" class = "input"
                              size = 20 maxlength = 200 class="textPage">
                        </div>

                        <br>
                    </td>
                    <td bgcolor = "#C2C2C2">
                        &nbsp;
                    </td>
                </tr>
            </table>
            <br>

            <div align = "center">
                <table border = "0" cellpadding = "2" cellspacing = "0" width = "300" bgcolor = "#ffffff">
                    <tr>
                        <td valign = "center" width = "3000"><button type="submit" style="background-color:transparent; border-color:transparent;"> 
                        <img src="submit.png" width = "130" height = "60""/></button>
                        </td>

                        <td>&nbsp;&nbsp;&nbsp;</td>

                        <td valign = "center" width = "400"
                            ><a href = "javascript:if(confirm('Are you sure you wish to cancel your changes?')) {document.location=document.location;}"                         
                                ><img width = "80" height = "70" src = "reload.png" border = "0" alt = "Reload Page" /></a>
                        </td>
                    </tr>

                    <tr>
                        <td align = "left" valign = "center">
                            <div id = "div_small_bold">
                                Submit and Preview 
                            </div>
                        </td>

                        <td>&nbsp;&nbsp;&nbsp;</td>

                        <td align = "center" valign = "center">
                            <div id = "div_small_bold">
                                Clear and Reload
                            </div>
                        </td>
                    </tr>
                </table>

    </center>
    </form> 
    </body>
</html>

0 个答案:

没有答案