0

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());
Matt Way
  • 32,319
  • 10
  • 79
  • 85
user3377635
  • 153
  • 1
  • 5
  • 12
  • What do oyu mean with *Amount of month*? Do you mean how often this month was selected before? Or do you mean the number representing the month (i.e. 1 for january, 3 for march ans 12 for december)? And what exactly is your problem? do you not know how to store a value in the database? Do you not know how to get the number for the selected month via `GET`? Please explain. – Andresch Serj May 22 '14 at 08:37
  • Please be aware that the mysql extension has been deprecated for quite some time now in favor of the mysqli and PDO extensions. It's use is highly discouraged. See http://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php – Oldskool May 22 '14 at 09:05

0 Answers0