将选择框中的值插入数据库mysql

时间:2015-02-15 22:10:08

标签: mysql

嗨,大家好,当我什么都不申请时发生我在mysql中检查表并且它是空的:/ 我不知道该怎么办我认为我的代码是正确的我不知道问题出在哪里我会成为林间空地如果你可以帮助我想要添加另一件事,如果价值已经在表中我想要求客户再次尝试,因为约会已经是令牌 php部分

<?php
if(isset($_POST['Submit'])) {
    // Fetch and clean the <select> value.
    // The (int) makes sure the value is really a integer.
    $qty = (int)$_POST['qantity'];

    // Create the INSERT query.
    $sql = "INSERT INTO rdv (time)
            VALUES ({$qty})";
    // Connect to a database and execute the query.
    $dbLink = mysql_connect('localhost', 'root', '') or die(mysql_error());
              mysql_select_db('login') or die(mysql_errno());

    $result = mysql_query($sql);


    // Check the results and print the appropriate message.
    if($result) {
        echo "Record successfully inserted!";
    }
    else {
        echo "Record not inserted! (". mysql_error() .")";
    }
}
?>

Html部分

 <html>
    <head>
        <title>Cabinet d'entaire</title>
        <link href="css/style.css" rel="stylesheet" type="text/css"  media="all" />
        <link href='http://fonts.googleapis.com/css?family=Ropa+Sans' rel='stylesheet' type='text/css'>
        <link href="css/select.css" rel="stylesheet" type="text/css"  media="all" />
    </head>
    <body>
        <!--start-wrap-->

            <!--start-header-->
            <div class="header">
                <div class="wrap">
                <!--start-logo-->
                <div class="logo">
                    <a href="index.html"><img src="images/logo.png" title="logo" /></a>
                </div>
                <!--end-logo-->
                <!--start-top-nav-->
                <div class="top-nav">
                    <ul>
                        <li><a href="index.html">Home</a></li>
                        <li><a href="about.html">About</a></li>
                        <li><a href="services.html">services</a></li>
                        <li><a href="blog.html">blog</a></li>
                        <li><a href="contact.html">contact</a></li>
                    </ul>                   
                </div>
                <div class="clear"> </div>
                <!--end-top-nav-->
            </div>
            <!--end-header-->
        </div>
            <div class="clear"> </div>
           <div class="wrap">
            <div class="contact">
            <div class="section group">             
                <div class="col span_1_of_3">
                    <div class="contact_info">
                        <h2>Hi Patient</h2><br />
                            <div>
                                <li><img width="100%" height="210" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="images/patient.jpg" alt=""></li>
                            </div>
                    </div>

                </div>              
                <div class="col span_2_of_3">
                  <div class="contact-form">
                    <h2> Would you like to have Consultation or an Operation? </h2><br /> 
                        <form>

                           <div>
                           <div>
                        <span>Which day ?</span>
                                <span><input type="text" value=""></span>  <br />       
</div>
<label>
 <form action="id4.php" method="post">
   <select name="qantity">
        <option selected> choose Consultation Time  </option>
        <option value="9">  At 9</option>
        <option value="10">  At 10</option>
        <option value="11">  At 11</option>
        <option value="12">  At 12</option>
    </select>
</label>
<br /><br /> 
<br /><br /> 
<label>
    <select>
        <option selected> choose Operation Time  </option>
        <option>  At 14</option>
        <option>  At 15</option>
        <option>  At 16</option>
        <option>  At 17</option>
    </select>
</label>
 <div>
                                <br /> <span><input type="submit" name="Submit" value="Submit"></span>
                          </div>
                          </div>

                        </form>
                    </div>
                </div>              
              </div>
                 <div class="clear"> </div>
    </div>
    <div class="clear"> </div>
            </div>
          <div class="clear"> </div>
           <div class="footer">
             <div class="wrap">
            <div class="footer-left">
                    <ul>
                        <li><a href="index.html">Home</a></li>
                        <li><a href="about.html">About</a></li>
                        <li><a href="services.html">services</a></li>
                        <li><a href="blog.html">blog</a></li>
                        <li><a href="contact.html">contact</a></li>
                    </ul>
            </div>
            <div class="footer-right">
                <p>Medicare | Design By <a href="http://w3layouts.com/">W3Layouts</a></p>
            </div>
            <div class="clear"> </div>
           </div>
           </div>
        <!--end-wrap-->
    </body>
</html>

0 个答案:

没有答案