Help me with code for sales order in which one can add multiple item and can store it in database. Example.
-------------------------------------------------------------------------------------------
item name | item rate | item quantity| total amount|
LEd 2100 2 4200 |Edit|Delete (line 1)
Mouse 100 4 400 |Edit|Delete (line 2)
Item list | auto fill | manual | Auto fill | Add (line 3)


Grand Total | 4400 |

**Submit**

Item list is taken from databse. item rate should be come auto as specified in database and total amount should come automatically. after pressing add button next line come automatically as line 3 and the added line must look like line 1 and line 2 with edit and delete option. after submitting the form all entry inserted into database.

Help will be highly appreciated.

the work I have done is .....


------------------------------------------------------------------------------------------------------

fee.php


PHP Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Fee</title>
<style type="text/css">
<!--
body {
    background-image: url(images/background4.jpg);
}
body,td,th {
    font-size: 18px;
}
-->
</style>
<style type="text/css">
<!--
h2 {
    font-size: 36px;
}
h3 {
    font-size: 36px;
}
a:link {
    color: #CCC;
}
-->
</style>
<script src="SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>
<link href="SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css" />
</head>

<link href="/Styles/MainStyle.css" rel="stylesheet" type="text/css">   
<link href="/Styles/PrintStyle.css" rel=" stylesheet" 
      type="text/css" media="print">  
      <style type="text/css" media="print">    
      .NonPrintable
    {
      display: none;
    }  </style>

<body><center>
</center>
 <form method="post" action="checkfee.php">
<center>
<table width="954" height="265" border="0">
  <tr bgcolor="#00CCCC">
    <td width="948" height="261" bgcolor="#CCCCCC"><table width="947" height="90" >
      <tr>
          <td width="939" height="84"><center><h1>&nbsp;</h1>
          </center></td>
        </tr>
      </table><center>
        <table width="941">
          <tr>
            <td width="81">&nbsp;</td>
            <td width="723"><strong><center>
Fee
            </center></strong></td>
            <td width="121">Rs. 
            <?php
$host
="localhost";
$username="root";
$password="";
$database="maggot";
mysql_connect($host,$username,$password);  
mysql_select_db("$database");
$query mysql_query("SELECT MAX(rate) FROM `billing_type` 
WHERE department='Fee'"
);
$results mysql_fetch_array($query);
$cur_auto_id $results['MAX(rate)'] ;
echo 
$cur_auto_id;
//echo" <input type='text' name='recieved_in_words' value='$cur_auto_id' />";

?>
             only</td>
          </tr>
        </table>
      </center>
      <table width="948" height="30" >
          <tr>
            <td width="223" height="24" align="left">
                <label>Bill No :
                 <?php
$host
="localhost";
$username="root";
$password="";
$database="maggot";

mysql_connect($host,$username,$password);
  
mysql_select_db("$database");

$query mysql_query("SELECT MAX(bill) FROM `arv` 
WHERE department='Fee'"
);
$results mysql_fetch_array($query);
$cur_auto_id $results['MAX(bill)'] + 1;
echo 
$cur_auto_id;

?>

                                </label>
            </td>
            <td width="492"><strong><center>Cash Reciept</center> </strong></td>
            <td width="217" align="right">
              <label>Date :
                <?php
echo date("Y/m/d"); 
?>
              </label>
            </td>
          </tr>
      </table>
        <center>
        </center>
       <table width="950" height="30">
        <tr>
          <td width="377" height="24" align="left">
            <label>Item Name :<span id="sprytextfield1">
              <input type="text" name="itemname" id="text1" />
              <span class="textfieldRequiredMsg">A value is required.</span></span></label>
          </td>
          <td width="353" align="left">
            <label>rate :<span id="sprytextfield2">
            <input type="text" name="rate" id="text2" />
            <span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span></label>
        </td>
          <td width="204" align="right">
            <label>quantity :<span id="sprytextfield3">
              <input type="text" name="quantity" id="text3" />
              <span class="textfieldRequiredMsg">A value is required.</span></span></label>
         </td>
          </tr>
      </table>
       <table width="950" height="28" >
         <tr>
          <td width="251" align="left">
            <label>total :<span id="sprytextfield4">
              <input type="text" name="total" id="text4" />
              <span class="textfieldRequiredMsg">A value is required.</span></span></label>
          </td>
          <td width="687" align="left">
            <label>grand total :<span id="sprytextfield5">
              <input type="text" name="grandtotal" id="text5" />
              <span class="textfieldRequiredMsg">A value is required.</span></span></label>
        </td>
          </tr>
      </table>
 
      <table width="950" height="30">
        <tr>
          <td width="259" height="24"><p>Signature of .................................</p></td>
          <td width="480">&nbsp;</td>
          <td width="195"><p>Signature of...................</p></td>
          </tr>
      </table>
      <table width="945" border="0">
        <tr>
          <td width="468"><label>
            <center><input type="submit" name="button" id="button" value="Submit" class="NonPrintable"/>
          </center></label></td>
          <td width="467"><center></center></td>
        </tr>
      </table></td>
  </tr>
</table>
</center></form>
<script type="text/javascript">
<!--
var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1");
var sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2", "integer");
var sprytextfield3 = new Spry.Widget.ValidationTextField("sprytextfield3");
var sprytextfield4 = new Spry.Widget.ValidationTextField("sprytextfield4");
var sprytextfield5 = new Spry.Widget.ValidationTextField("sprytextfield5");
//-->
</script>
</body>
</html>

----------------------------------------------------------------------------------------------------------------

checkfee.php

PHP Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>fee</title>
<style type="text/css">
<!--
body {
    background-image: url(images/background4.jpg);
}
body,td,th {
    font-size: 18px;
}
-->
</style>
<style type="text/css">
<!--
h2 {
    font-size: 36px;
}
h3 {
    font-size: 36px;
}
a:link {
    color: #CCC;
}
-->
</style></head>

<link href="/Styles/MainStyle.css" rel="stylesheet" type="text/css">   
<link href="/Styles/PrintStyle.css" rel=" stylesheet" 
      type="text/css" media="print">  
      <style type="text/css" media="print">    
      .NonPrintable
    {
      display: none;
    }  </style>

<body><center>
</center>
 <form method="post" action="">
<center>
<table width="954" height="265" border="0">
  <tr bgcolor="#00CCCC">
    <td width="948" height="261" bgcolor="#CCCCCC"><table width="947" height="90" >
      <tr>
          <td width="939" height="84"><center><h1>&nbsp;</h1>
          </center></td>
        </tr>
      </table><center>
        <table width="941">
          <tr>
            <td width="81">&nbsp;</td>
            <td width="766"><strong><center>
              
Fee
            </center></strong></td>
            <td width="78">Rs. <?php
$host
="localhost";
$username="root";
$password="";
$database="maggot";
mysql_connect($host,$username,$password);  
mysql_select_db("$database");
$query mysql_query("SELECT MAX(rate) FROM `billing_type` 
WHERE department='Fee'"
);
$results mysql_fetch_array($query);
$cur_auto_id $results['MAX(rate)'] ;
echo 
$cur_auto_id;
//echo" <input type='text' name='recieved_in_words' value='$cur_auto_id' />";

?> only</td>
          </tr>
        </table>
      </center>
      <table width="948" height="30" >
          <tr>
            <td width="223" height="24" align="left">
                <label>Bill No :
                  <?php
$host
="localhost";
$username="root";
$password="";
$database="maggot";

mysql_connect($host,$username,$password);
  
mysql_select_db("$database");
$department=$_POST['item'];


$query mysql_query("SELECT MAX(bill_no) FROM `arv` ");
$results mysql_fetch_array($query);
$cur_auto_id $results['MAX(bill_no)'] + 1;
echo 
$cur_auto_id;

?>

                </label>
            </td>
            <td width="492"><strong><center>Cash Reciept</center> </strong></td>
            <td width="217" align="right">
              <label>Date :
                <?php
echo date("Y/m/d"); 
?>
              </label>
            </td>
          </tr>
      </table>
        <center>
        </center>
       <table width="950" height="30">
        <tr>
          <td width="435" height="24" align="left">
            <label>Name :
              <?php

print $_POST['itemname'];

?>
              </label>
          </td>
          <td width="295" align="left">
            <label>Age :
              <?php

print $_POST['rate'];

?>
            </label>
        </td>
          <td width="204" align="right">
            <label>Sex :
              <?php

print $_POST['quantity'];

?>
            </label>
         </td>
          </tr>
      </table>
       <table width="950" height="28" >
         <tr>
          <td width="435" align="left">
            <label>Ward :
              <?php

print $_POST['total'];

?>
              </label>
          </td>
          <td width="503" align="left">
            <label>Bed No. :
              <?php

print $_POST['grandtotal'];

?>
              </label>
        </td>
          </tr>
      </table>
 
      <table width="950" height="30">
        <tr>
          <td width="259" height="24"><p>Signature of .................................</p></td>
          <td width="480">&nbsp;</td>
          <td width="195"><p>Signature of...................</p></td>
          </tr>
      </table>
      <table width="945" border="0">
        <tr>
          <td width="468"><label>
            <center>
            </center></label></td>
          <td width="467"><center><input type="submit" name="button2" id="button2" value="Print" onclick="window.print();return false;" class="NonPrintable"/></center></td>
        </tr>
      </table></td>
  </tr>
</table>
</center></form>
</body>
</html>






<?php
require_once ('../connections/connection.php');


$bill_no=$_POST['bill_no'];
$date=date('Y/m/d');
$name=$_POST['itemname'];
$rate=$_POST['rate'];
$total=$_POST['total'];
$grandtotal=$_POST['grandtotal'];
$quantity=$_POST['quantity'];


$sql1="INSERT INTO arv ( user, bill, date, itemname, rate, quantity, total, grandtotal)

VALUES ('$sname', '$bill_no', '$date', '$itemname', '$rate', '$quantity', '$total', '$grandtotal' )"
;

mysql_query($sql1);


echo 
"Form Submitted";

?>