下拉选项用于在php嵌入式html中选择结束日期

Here i am going to add user information , when i add user information data gets inserted into user table and 10 chapter numbered from 1 to 10 is allocated to the same user and gets inserted to database row chapter_subscription .In chapter subscription table we have chapter number, start date,end date as a table names .But i want allow the user to change the end dates to 1 or 3 or 6 or 9 or 12 months respectively in the form of drop down style .I want to know how to create a drop down for displayed chapter subscription's end date.I am new to php please help me thank you. insert_dummy.php

<html>
<head><title>Insertion</title>

</head>
<body>
<style>

#colour {
text-decoration:none;
}
</style>
<div id="display">
<?php

    error_reporting(0);
    include('db.php');




    $userName=mysql_real_escape_string($_POST['userName']);



    $userEmail=mysql_real_escape_string($_POST['userEmail']);
    $userPassword=mysql_real_escape_string($_POST['userPassword']);
    $expiry_date1=mysql_real_escape_string($_POST['expiry_date']);
    $expiry_date=date("Y-m-d" ,strtotime($expiry_date1));
    $end_date1=mysql_real_escape_string($_POST['end_date']);
    $end_date=date("Y-m-d",strtotime($end_date1));



     $regDate = date("Y-m-d");



    function generateCode($characters) 
    {
        $possible = '23456789abcdefghjkmnpqrstuvwxyz!@#$%^&*';
        $code = '';
        $i = 0;
        while ($i < $characters) { 
            $code .= substr($possible, mt_rand(0, strlen($possible)-1), 1);
            $i++;
        }
        return $code;
    }

    $registration_key=generateCode(10);



    $str="insert into coeds_user(userName,userEmail,userPassword,regDate,expiry_date,registration_key) values('$userName','$userEmail','$userPassword','$regDate','$expiry_date','$registration_key')";


    $query=mysql_query($str);
    $userid=mysql_insert_id();
    if($query)
    {
    $display="Success";
    }

    else
    {
    $display= "Failed";
    }








    $string="select * from coeds_user where userId=$userid";
    $query2=mysql_query($string);
    $display.="<table border='1' align='center'>";
    $display.="<tr><th>UserName</th><th>UserEmail</th><th>UserPassword</th><th>RegDate</th><th>ExpiryDate</th><th>RegistrationKey</th><th colspan='3'>Action</th></tr>";
    while($result=mysql_fetch_array($query2))
    {
    $display.="<tr>";

    $display.="<td>".$result['userName']."</td>";
    $display.="<td>".$result['userEmail']."</td>";
    $display.="<td>".$result['userPassword']."</td>";
    $display.="<td>".$result['regDate']."</td>";
    $display.="<td>".$result['expiry_date']."</td>";
    $display.="<td>".$result['registration_key']."</td>";
    $display.="<td><a id='colour' class='tooltip' title='Edit' href='user_update.php?user_Id=".$result['userId']."'><img id='image' src='./images/small.gif'/></a></td>";
    $display.="<td><a id='colour' class='tooltip' data-toggle='tooltip' title='Delete' href='user_delete.php?user_Id=".$result['userId']." '><img id='image' src='./images/trash.png'/></a></td>";



    $display.="</table>";

     $end_date1 = date('Y-m-d', strtotime("+3 months"));
     $end_date2 = date('Y-m-d', strtotime("+6 months"));
     $end_date3 = date('Y-m-d', strtotime("+9 months"));
     $page="";
  <?php
    }
    $str="select chapter_no from chapter_details ";


    $query7=mysql_query($str);

    $count=mysql_num_rows($query7);
    for($i=0;$i<$count;$i++)
    {
    $chap_lic=generateCode(50);
    $chapter_no=mysql_result($query7,$i,'chapter_no');
    $start_date=date('Y-m-d');
    $expiry_date=mysql_real_escape_string($_POST['end_date']);
    $end_date=date("Y-m-d" ,strtotime("+3 months"));
    /*$end_date1=mysql_real_escape_string($_POST['end_date']);
    $end_date=date("Y-m-d",strtotime($end_date1));*/
    $s="insert into chapter_subscriptions (userId,chapter_no,start_date,end_date) values($userid,$chapter_no,'$start_date','$end_date')";
    $end_date=date("Y-m-d" ,strtotime("+3 months"));

    $query8=mysql_query($s);
    }
    $strings="select * from chapter_subscriptions where userId=$userid";
    $query9=mysql_query($strings);
    $display.="<table border='1' align='center'>";
    $display.="<tr><th>ChapterNumber</th><th>StartDate</th><th>EndDate</th><th colspan='2'>Action</th></tr>";
    while($result=mysql_fetch_array($query9))
    {
    $display.="<tr>";
    $display.="<td>".$result['chapter_no']."</td>";
    $display.="<td>".$result['start_date']."</td>";

    for(i=1;i<12;i+2)
    {
    $display.="<td>".$result['end_date']."</td>";

    }
    $display.="<td><a id='colour' class='tooltip' title='Edit' href='chapter_subscription_update.php?user_Id=".$result['userId']."'><img id='image' src='./images/small.gif'/></a></td>";
    $display.="<td><a id='colour' class='tooltip' data-toggle='tooltip' title='Delete' href='chapter_subscription_delete.php?user_Id=".$result['userId']." '><img id='image' src='./images/trash.png'/></a></td>";

    $display.="</tr>";
    }
    $display.="</table>";


    echo $display;


    ?>
    </div>
     <script type="text/javascript">
        $(document).ready(function() {
        $( "#expiry_date" ).datepicker();
        $("#menuwrapper").hide();
        $("#unicode").click(function() {
            $("#menuwrapper").slideToggle(500);
        });
        });


    </script>   


    </body>
    </html>

In HTML you can use the <select> tag, which will allow you to create a form input field, which behaves like a dropdown. To submit its values, you have to use a <form> tag. In your particular case, it would be done like this:

<form action="page_which_will_process_inputs.php" method="POST">
  End date: 
  <select name="enddate">
    <option value="1month">1 month</option>
    <option value="3months">3 months</option>
    <option value="6months">6 months</option>
    <option value="12months">12 months</option>
  </select>
</form>

To access the data passed through POST in the file page_which_will_process_inputs.php (or any filename you like), you have to access the $_POST superglobal:

$enddate = $_POST["enddate"];
switch ($enddate) {
  case "1month":
    // Do 1 month logic
    break;
  ...
  case "12months":
    // Do 12 months logic
    break;
}

You would replace // Do x month(s) logic with your SQL UPDATE statement and then run the statement after the switch loop, for example.