我有一个表单,其中包含下拉日期,日期和金额。当用户选择月份作为1月份时输入的金额去存储在月份为jan的数据库中。假设用户选择月份,可能在月份中输入的金额可以更新。请告诉我如何我能做到吗我是php新手。我有一个数据库,如jan,feb,...等列
数据库设计
一月| 2月| 3月| ......... |日期|
在网页jan,feb ...是下拉菜单,日期和金额 当用户选择jan时,31-1-2014,1600amount。 数量为1600,并存储在月份为jan的数据库中。 我怎样才能做到这一点?这是代码
$(function() {
$("#XISubmit").click(function(){
var id=document.forms["XIForm"]["id"].value;
var fathername=document.forms["XIForm"]["fathername"].value;
var month=document.forms["XIForm"]["month"].value;
var date=document.forms["XIForm"]["date"].value;
var amount=document.forms["XIForm"]["amount"].value;
document.getElementById("XIForm").submit();
});
<label type="text" name="month" maxlength="50" size="30" class="label">Month</label><br />
<select name="month" placeholder="" class="input" style="width: 380px;" >
<option name="jan" value="January">January</option>
<option value="February">February</option>
<option value="March">March</option>
<option value="April">April</option>
<option value="May">May</option>
<option value="June">June</option>
<option value="July">July</option>
<option value="August">August</option>
<option value="September">September</option>
<option value="October">October</option>
<option value="November">November</option>
<option value="December">December</option>
</select><br/><br/>
<label type="text" name="date" maxlength="50" size="30" class="label">Date Which amount received</label><br />
<input type="date" name="date" placeholder="" class="input" style="width: 360px;"/><br /><br />
<label type="text" name="amount" maxlength="50" size="30" class="label">Amount</label><br />
<input name="amount" placeholder="" class="input" size="40"/><br /><br />
php code
php code
$id="";
$name="";
$month="";
$date="";
$amount="";
if($_REQUEST["formType"] == "reg") {
$id=$_REQUEST["id"];
$fathername= $_REQUEST["fathername"];
$month=$_REQUEST["month"];
$date=$_REQUEST["date"];
$amount=$_REQUEST["amount"];
$formType= "reg";
}
$username = "root";
$password = "";
$hostname = "localhost";
$db = "anthonys";
//connection to the database
$dbhandle = mysql_connect($hostname, $username, $password) or
die("Unable to connect to MySQL");
mysql_select_db($db,$dbhandle) or die('cannot select db');
mysql_query("update member set month='$month', date='$date',amount='$amount'
Where id='$id')") or die(mysql_error());