I have a form which contains months as drop down, date and amount. When the user select the month as january the amount entered in january as to go and stored in the databse whose month is jan.Suppose the user selects month as may the amount entered in the month of may as to be updated.Please tell me how can i do this. I m new to php. I have a database which as the columns such as jan,feb,...etc
database design
jan|feb|mar|.........|date|
in the webpage jan,feb... are dropdown menus,date and amount when the user selects jan,31-1-2014,1600amount. the amount 1600 as to go and store in the database where the month is jan. how can i do this? here is the code
$(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());