calculated field - Php calculation is posting as 0 -


i having problem getting calculation post 0. other post has correct info form calculation not working. data comes inputs , calculation of total pallets works. total price.

the whole form:

if(!checkadmin()) { header("location: login.php"); exit(); }  $page_limit = 10;      // filter values foreach($_get $key => $value) { $get[$key] = filter($value); }  foreach($_post $key => $value) { $post[$key] = filter($value); }   $rs_all = mysql_query("select count(*) total_all users") or     die(mysql_error());   list($all) = mysql_fetch_row($rs_all); ?> <?php $rs_pickup = mysql_query("select count(*) total_all pickups") or     die(mysql_error()); list($pickup) = mysql_fetch_row($rs_pickup); ?> <?php $sql="select companyid, company company ";  $result=mysql_query($sql) or die(mysql_error());   $options="";  while ($row=mysql_fetch_array($result)) {   $id=$row["companyid"];  $thing=$row["company"];  $options.="<option value=\"$id\">".$thing.'</option>';  }  ?> <?php  ?> <?php  $err = array();  if($_post['dopickup'] == 'enter pickup')  if(empty($err)) {   $companyid = $_post['companyid'];  $sql_grd = "select companyid, grade_a_pu, grade_b_pu, grade_c_pu, ns_pu, custom_pu company companyid = $companyid"; $result_grd=mysql_query($sql_grd) or die(mysql_error()); while ($row_grd=mysql_fetch_array($result_grd))  {  $price_a = $row_grd["grade_a_pu"]; $price_b = $row_grd["grade_b_pu"]; $price_c = $row_grd["grade_c_pu"]; $price_ns = $row_grd["ns_pu"]; $price_cus = $row_grd["custom_pu"];  } $total_credit = (($_post['grade_a_pal']*$price_a)+($_post['grade_b_pal']*$price_b)+($_post['grade_c_pal']*$price_c)+($_post['ns_pal']*$price_ns)+($_post['cus_pal']*$price_cus));  $sql_insert = "insert `pickups`          (`companyid`,`pu_date`,`trail_num`,`grade_a_pal`,`grade_b_pal`,`grade_c_pal`,`ns_pal`,`cus_pal`,`pal_pu`,`credit`)         values          ('$_post[companyid]','$_post[pu_date]','$_post[trail_num]','$_post[grade_a_pal]','$_post[grade_b_pal]','$_post[grade_c_pal]','$_post[ns_pal]','$_post[cus_pal]','$_post[pal_pu]','$total_credit')";  mysql_query($sql_insert,$link) or die("insertion failed:" . mysql_error());  }  ?>  <html> <head> <title>usmi pallets, inc. :: pickup entry page</title> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"> <link href="styles.css" rel="stylesheet" type="text/css"> <link rel="stylesheet"  href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js">     </script> <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script> <script type="text/javascript"> $(document).ready( function() {    $("#datepicker").datepicker({   dateformat: 'yy-mm-dd',   changemonth: true,   changeyear: true   });  });   </script>  </head>    <body>  <table width="100%" border="0" cellspacing="0" cellpadding="0">  <?php include("header.php"); ?>  <tr> <td colspan="3" height="23" valign="top" style="background-color:#a42914 "> </td> </tr>  <?php include("admin_menu.php"); ?>  <td width="800" valign="top" style="padding: 10px;">    <table width="100%" border="0" cellpadding="5" cellspacing="0" class="myaccount">     <tr>       <td>total pickups: <?php echo $pickup;?></td>      </tr>     </table>     <p><?php    if(!empty($msg)) {   echo $msg[0];   }   ?></p>      <table width="80%" border="0" align="center" cellpadding="10" cellspacing="0" style="background-color: #e4f8fa;padding: 2px 5px;border: 1px solid #cae4ff;" >     <tr>       <td><form name="form1" method="get" action="pickup_ent.php">            <p align="center">search account:             <select name=companyid id="q">          <option value=0>choose         <?=$options?>         </select>              <br>             </p>               <p align="center">              <input name="dosearch" type="submit" id="dosearch2" value="search">           </p>           </form></td>     </tr>   </table>   <p>    <?php if ($get['dosearch'] == 'search') {      $sql = "select * pickups companyid = '$_request[companyid]' order pu_date desc";     $rs_total = mysql_query($sql) or die(mysql_error());   $total = mysql_num_rows($rs_total);    if (!isset($_get['page']) )     { $start=0; } else     { $start = ($_get['page'] - 1) * $page_limit; }    $rs_results = mysql_query($sql . " limit $start,$page_limit") or die(mysql_error());   $total_pages = ceil($total/$page_limit);    ?>  <?php     // outputting pages     if ($total > $page_limit)     {     echo "<div><strong>pages:</strong> ";     $i = 0;     while ($i < $page_limit)     {       $page_no = $i+1;     $qstr = ereg_replace("&page=[0-9]+","",$_server['query_string']);     echo "<a href=\"pickup_ent.php?$qstr&page=$page_no\">$page_no</a> ";     $i++;     }     echo "</div>";     }  ?>     <form name "searchform" action="pickup_ent.php" method="post">            <table width="100%" border="0" align="center" cellpadding="2" cellspacing="0">      <tr bgcolor="#e6f3f9">  <td class="myheader">id</td> <td class="myheader">company #</td> <td class="myheader">date</td> <td class="myheader">trailer number</td> <td class="myheader">grade a</td> <td class="myheader">grade b</td> <td class="myheader">grade c</td> <td class="myheader">non-std</td> <td class="myheader">custom</td> <td class="myheader">total pickup</td> <td class="myheader">total credit</td> </tr> <tr> <td>&nbsp;</td> <td>&nbsp;</td> <td>&nbsp;</td> <td>&nbsp;</td> <td>&nbsp;</td> <td>&nbsp;</td> <td>&nbsp;</td> <td>&nbsp;</td> <td>&nbsp;</td> <td>&nbsp;</td> <td>&nbsp;</td> </tr>  <?php while ($rrows = mysql_fetch_array($rs_results)) {?>  <tr>          <td> <div align="center"><?php echo $rrows['pickup_id']; ?></div>   </td>         <td> <div align="center"><?php echo $rrows['companyid']; ?></div></td>         <td> <div align="center"><?php echo $rrows['pu_date']; ?></div></td>         <td> <div align="center"><?php echo $rrows['trail_num'];?></div></td>         <td> <div align="center"><?php echo $rrows['grade_a_pal'];?></div></td>         <td> <div align="center"><?php echo $rrows['grade_b_pal'];?></div></td>         <td> <div align="center"><?php echo $rrows['grade_c_pal'];?></div></td>         <td> <div align="center"><?php echo $rrows['ns_pal'];?></div></td>         <td> <div align="center"><?php echo $rrows['cus_pal'];?></div></td>         <td> <div align="center"><?php echo $rrows['pal_pu'];?></div></td>         <td> <div align="center">$<?php echo $rrows['credit'];?></div></td>         <td width="10%"><a href="edit_pu.php?pickup_id=<?php echo $rrows['pickup_id']; ?>">edit</a>&nbsp;<a href="delete_pu.php?pickup_id=<?php echo $rrows['pickup_id']; ?>">delete</a></td>                    </tr>       <tr>         <?php } ?>     </table>     <p><br>     </form>   <?php } ?>    &nbsp;</p>      <h2><font color="#ff0000">pickup entry      page</font></h2>    <p>&nbsp;</p>    <form name "pickupform" action="pickup_ent.php" method="post">   <table width="80%" border="0" align="center" cellpadding="10" cellspacing="0" style="background-color: #e4f8fa;padding: 2px 5px;border: 1px solid #cae4ff;" >     <tr>       <td>       account:          <select name=companyid>          <option value=0>choose          <?=$options?>          </select> </td>     </tr>         <tr>        <td>date: <input name="pu_date" type="text" id="datepicker" /></td>        </tr>        <tr>        <td>trailer #:<select name="trail_num" id="trail_num">                     <option selected value=""></option>                     <option value="1986-1">1986-1</option>                     <option value="1986-2">1986-2</option>                     <option value="1986-3">1986-3</option>                     <option value="1986-4">1986-4</option>                     <option value="1986-5">1986-5</option>                     <option value="1986-6">1986-6</option>                     <option value="1986-7">1986-7</option>                     <option value="1986-8">1986-8</option>                     <option value="1986-9">1986-9</option>                     <option value="1986-10">1986-10</option>                     <option value="1986-11">1986-10</option>                     <option value="1986-12">1986-12</option>                     </select></td>     </tr>         <tr>        <td>grade pallets: <input id="grade_a_pal" name="grade_a_pal" type="text" size="8"> </td>        </tr>        <tr>        <td>grade b pallets: <input id="grade_b_pal" name="grade_b_pal" type="text" size="8"> </td>        </tr>        <tr>        <td>grade c pallets: <input id="grade_c_pal" name="grade_c_pal" type="text" size="8"> </td>        </tr>        <tr>        <td>non-standard pallets: <input id="ns_pal" name="ns_pal" type="text" size="8"></td>        </tr>        <tr>        <td>custom pallets: <input id="cus_pal" name="cus_pal" type="text" size="8"></td>        </tr>        <tr>      <tr>        <td>total pallets picked up:          <input id="pal_pu" name="pal_pu" type="text" size="8" readonly></td>        </tr>         <td><input name="dopickup" type="submit" id="dopickup" value="enter pickup"></p>         </td>      </tr>    </table>   <script> $(document).ready(function() {  //this calculates values automatically  sum();  $("#grade_a_pal, #grade_b_pal, #grade_c_pal, #cus_pal").on("keydown keyup",   function() { sum();  }); });  function sum() {  var grade_a_pal = document.getelementbyid('grade_a_pal').value;  var grade_b_pal = document.getelementbyid('grade_b_pal').value;  var grade_c_pal = document.getelementbyid('grade_c_pal').value;  var ns_pal = document.getelementbyid('ns_pal').value;  var cus_pal = document.getelementbyid('cus_pal').value;  var result = parseint(grade_a_pal) + parseint(grade_b_pal) +  parseint(grade_c_pal) + parseint(ns_pal) + parseint(cus_pal);  if (!isnan(result)) {  document.getelementbyid('pal_pu').value = result;  }  } </script>   </form>    <p>&nbsp;</p>   <p>&nbsp;</p> <p>&nbsp;</p></td> <td width="12%">&nbsp;</td> </tr> <tr> <td colspan="3" height="43" valign="top" style="background-color:#a42914 "> <table width="766" style="height:100% " border="0" cellspacing="0" cellpadding="0">    <tr>     <td valign="top" class="myfooter"> <div style="margin:12px 0px 0px 31px; ">  &copy; 2012 usmi pallets, inc. rights reserved </div>      </td>   </tr>   </table>  </td> </tr> </table> </body> </html> 

it appears using $_post (lower case) instead of $_post (uppercase) pallets vars.

try outputting print_r($_post) see getting in $_post array. referencing wrong vars.


Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -