WaleedaaN 0 Newbie Poster

Dear all,


i have project for invoice system.
i use in this project php,mysql,html,javascript


first mysql table's

Products:
id,name,price

billing:
id,products,total_price

now i have create php file

with tables to get all product from products db to show in invoice file

javascript

<script  type="text/javascript"> 
  function toogle(element){ 


  var c = parseInt(element.value, 10); 
c = parseInt(element.value, 10); 
 if(element.checked) 
 { 
 c =  parseInt(document.getElementById('hel').value, 10) + c; 

 }
 else{
  c =  parseInt(document.getElementById('hel').value, 10) - c;
  }
  document.getElementById('hel').value = c; 
  document.getElementById('hel2').value = c; 
  }
  console.log();
  </script>
  
  <script language="Javascript">
  <!--

   function checkName(nameObj, displayObj) {
    if ( nameObj.value.length < 1 )
      alert("Please enter your number discount in the box!");
    else
      displayObj.value=document.getElementById('hel').value - nameObj.value;
   }
	
 // --></script>
  <SCRIPT language=Javascript>
      <!--
      function isNumberKey(evt)
      {
         var charCode = (evt.which) ? evt.which : event.keyCode
         if (charCode > 31 && (charCode < 48 || charCode > 57))
            return false;

         return true;
      }
      //-->
   </SCRIPT>

php file

echo "
<form method='POST' action='?admin=invoice&do=add'>
<table border='0' width='80%' id='table2' cellspacing='0' cellpadding='0' height='30' >
	<tr>
		<td background='images/hbg.gif'>
		<p align='center'><b><font face='Tahoma' color='#FFFFFF'>New Invoice</font></b></td>
	</tr>
</table>
<table border='1' width='80%' id='table1' cellpadding='0' dir=ltr style='border-collapse: collapse' bordercolor='#C0C0C0'>
	<tr>
		<td width='222' align='center' bgcolor='#F3F3F3'>
		<font face='Tahoma' size='2' color='#0000FF'>Customer</font></td>
		<td>&nbsp;<select size='1' name='customer' dir='ltr'>
		<option value='error' selected>select customer</option>	
		
		";

		$result = mysql_query("SELECT * FROM users WHERE status='customer'");
$count=mysql_num_rows($result); 
			if ($count == "0") {
	echo "<option value='error'>there is not customers</option>";
	}
	else {
			while($row = mysql_fetch_array($result))
  {
   $id = $row["id"];
  $name = $row["name"];
		
		echo "<option value='$id'>$name</option>";
		}
		}
		echo"
		</select>
		</td>
	</tr>
	<tr>
		<td width='222' align='center' bgcolor='#F3F3F3'>
		<font face='Tahoma' size='2' color='#0000FF'>Products</font></td>
		<td>";
				echo "<table border=0 width='100%' align=center valign=top  class=table><tr>";
$cols=1;
$presult = mysql_query("SELECT * FROM products");
while($prow = mysql_fetch_array($presult))
  {
   $productid = $prow["id"];
  $pname = $prow["name"];
  $price = $prow["price"];
  echo "<td  valign=top > ";
  echo "

<table border='0' width='100%' cellspacing='0' cellpadding='0'>
		<tr>
		<td> 
		<input name=\"productsid[]\" type=\"checkbox\"  id=\"hello\" value=\"$price\" onclick=\"toogle(this)\"><font face='Tahoma' size='2'>$pname</font><font face='Tahoma' color=#ff000 size='1'> ($price.$site_omla)</font>
		</td>
	</tr></table>
";
echo "</td >";
    if($cols%3==0){echo "</tr>";}
    $cols++;
		}
		echo"</table>";
		
		echo"</td>
	</tr>
	<tr>
		<td width='222' align='center' bgcolor='#F3F3F3' height='25'>
		<font face='Tahoma' size='2' color='#0000FF'>Date Start</font></td>
		<td height='25'><font face='Tahoma'><font size='2'>&nbsp;Day:
		</font><font face='Atah'>
		<select name='sday' size='1' dir='ltr'>
		<option value='1'>1</option>
		<option value='2'>2</option>
		<option value='3'>3</option>
		<option value='4'>4</option>
		<option value='5'>5</option>
		<option value='6'>6</option>
		<option value='7'>7</option>
		<option value='8'>8</option>
		<option value='9'>9</option>
		<option value='10'>10</option>
		<option value='11'>11</option>
		<option value='12'>12</option>
		<option value='13'>13</option>
		<option value='14'>14</option>
		<option value='15'>15</option>
		<option value='16'>16</option>
		<option value='17'>17</option>
		<option value='18'>18</option>
		<option value='19'>19</option>
		<option value='20'>20</option>
		<option value='21'>21</option>
		<option value='22'>22</option>
		<option value='23'>23</option>
		<option value='24'>24</option>
		<option value='25'>25</option>
		<option value='26'>26</option>
		<option value='27'>27</option>
		<option value='28'>28</option>
		<option value='29'>29</option>
		<option value='30'>30</option>
		<option value='31'>31</option>
		</select></font><font size='2'> - Month: </font>
		<select name='smonth' size='1' dir='ltr'>
		<option value='1'>1</option>
		<option value='2'>2</option>
		<option value='3'>3</option>
		<option value='4'>4</option>
		<option value='5'>5</option>
		<option value='6'>6</option>
		<option value='7'>7</option>
		<option value='8'>8</option>
		<option value='9'>9</option>
		<option value='10'>10</option>
		<option value='11'>11</option>
		<option value='12'>12</option>
		</select><font size='2'> <span lang='ar-kw'>-</span> Year: </font>
		</font><span lang='en-us'> <font face='Tahoma'>
		<input name=syear size='5' value='$ayear' ></font></span></td>
	</tr>
	<tr>
		<td width='222' align='center' bgcolor='#F3F3F3' height='25'>
		<font face='Tahoma' size='2' color='#0000FF'>Date Expired</font></td>
		<td height='25'><font face='Tahoma'><font size='2'>&nbsp;Day: </font>
		<font face='Atah'>
		<select name='eday' size='1' dir='ltr'>
		<option value='1'>1</option>
		<option value='2'>2</option>
		<option value='3'>3</option>
		<option value='4'>4</option>
		<option value='5'>5</option>
		<option value='6'>6</option>
		<option value='7'>7</option>
		<option value='8'>8</option>
		<option value='9'>9</option>
		<option value='10'>10</option>
		<option value='11'>11</option>
		<option value='12'>12</option>
		<option value='13'>13</option>
		<option value='14'>14</option>
		<option value='15'>15</option>
		<option value='16'>16</option>
		<option value='17'>17</option>
		<option value='18'>18</option>
		<option value='19'>19</option>
		<option value='20'>20</option>
		<option value='21'>21</option>
		<option value='22'>22</option>
		<option value='23'>23</option>
		<option value='24'>24</option>
		<option value='25'>25</option>
		<option value='26'>26</option>
		<option value='27'>27</option>
		<option value='28'>28</option>
		<option value='29'>29</option>
		<option value='30'>30</option>
		<option value='31'>31</option>
		</select></font><font size='2'> - Month: </font>
		<select name='emonth' size='1' dir='ltr'>
		<option value='1'>1</option>
		<option value='2'>2</option>
		<option value='3'>3</option>
		<option value='4'>4</option>
		<option value='5'>5</option>
		<option value='6'>6</option>
		<option value='7'>7</option>
		<option value='8'>8</option>
		<option value='9'>9</option>
		<option value='10'>10</option>
		<option value='11'>11</option>
		<option value='12'>12</option>
		</select><font size='2'> <span lang='ar-kw'>-</span> Year: </font>
		</font><span lang='en-us'> <font face='Tahoma'>
		<input name=eyear size='5' ></font></span></td>
	</tr>
	<tr>
		<td width='222' align='center' bgcolor='#F3F3F3' height='105'>
		<font face='Tahoma' size='2' color='#0000FF'>Notice</font></td>
		<td height='105'>&nbsp;<textarea rows='6' name='note' cols='40'></textarea></td>
	</tr>
	<tr>
		<td width='222' align='center' bgcolor='#F3F3F3'>
		<font color='#0000FF' size='2' face='Tahoma'>Total</font></td>
		<td><span lang='en-us'> &nbsp;<input name=\"total\" type=\"text\" id=\"hel\" size='5' value=\"0\" readonly='true'/>.$site_omla</span></td>
	</tr>
	<tr>
		<td width='222' align='center' bgcolor='#F3F3F3'>
		<font color='#0000FF' size='2' face='Tahoma'>Discount</font></td>
		<td><span lang='en-us'> &nbsp;<input name=\"discount\" value='0' size='5' onkeypress=\"return isNumberKey(event)\" >.$site_omla &nbsp;<input type=\"button\" value=\"Give Discount!\" OnClick=\"checkName(discount, subtotal);\"></span></td>
	</tr>
	<tr>
		<td width='222' align='center' bgcolor='#F3F3F3'>
		<font color='#0000FF' size='2' face='Tahoma'>Sub-Total</font></td>
		<td><span lang='en-us'> &nbsp;<input name=\"subtotal\" type=\"text\" id=\"hel2\" size='5' value=\"0\" readonly='true'/>.$site_omla</span></td>
	</tr>
	<tr>
		<td width='222' align='center' bgcolor='#F3F3F3'>
		<font face='Tahoma' size='2' color='#0000FF'>Send invoice to Customer by 
		e-mail</font></td>
		<td>&nbsp;<input type='checkbox' name='sendc' value='on' ></td>
	</tr>
	</table>
	<span lang='ar-kw'> 
<table border='0' width='80%' height=40 cellspacing='0' cellpadding='0'>
	<tr>
		<td>
	<span lang='ar-kw'> 
<input type='submit' value='Open New Invoice' name='B1' style='float: right'></td>
	</tr>
</table></form>

";

wha the problem!!!

i want add products name and price in table i create file php for that insert mysl.

butin open new invoice

i want when i check the checkbox down show me the price when i check multi box give me multi price like $10 + $10 = $20

when i uncheck box is going -

i create the javascript for that but when i insert the mysql db in billing table

i want the products table insert the id's of the products checkbox

send the id only like this 4,88,1

its send price money not id


please help me for that thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.