Jump to content



Welcome to KnowledgeSutra - Dear Guest , Please Register here to get Your own website. - Ask a Question / Express Opinion / Reply w/o Sign-Up!
- - - - -

Php Calculator


21 replies to this topic

#21 Guest_annie2011_*

  • Guests

Posted 25 May 2011 - 02:41 AM

Can anyone help me with the code for a simple php calculation that I can paste into my wordpress blog?

It only has one numerical input field I should think it would take someone who knows how under 10 mins to create the code which I would just want to paste into the wordpress page...

The customer types in a number (relating to years in this case)

i.e

Over ____ Years

and then then hits CALCULATE.

Answer ___________

The no. of years must then be multiplied by £1500 with an additional £1500 being added on top. i.e 10 years = £16,500


Let me know if you feel you can help...

#22 Guest_lily_*

  • Guests

Posted 07 October 2011 - 07:30 AM

hi, i am new with php. can you help me fix my script problems? its errors is 'undefined variable. how do i define variable? the script works best only with quality() but not others. please. thanks in advance.


<?PHP
$result=$_POST['day'];
$pv=$_POST['pv'];
$av=$_POST['av'];
$rr=$_POST['rr'];
$no=$_POST['no'];
$tt=$_POST['tt'];
$downtime=$_POST['downtime'];

 	 if(!$_POST['day'])
 	 {
 	  echo '
	 <form method="post" action="'.$_SERVER['PHP_SELF'].'">
	   	  
	  <select name="day">
 	   <option value="mon">Monday</option>
 	   <option value="tue">Tuesday</option>
 	   <option value="wed">Wednesday</option>
 	   <option value="thu">Thursday</option>
 	   <option value="fri">Friday</option>
	   <option value="sat">Saturday</option>
	   <option value="sun">Sunday</option>
 	  </select><br />
	  <td>Planned Volume:</td>
	  <input type="text" name="pv" size="5"><br />
	  <td>Actual Volume:</td>
 	  <input type="text" name="av" size="5"><br />
	  <td>Reject/Rework:</td>
	  <input type="text" name="rr" size="5"><br />
	  <td>Nett Output</td>
	  <input type="text" name="no" size="5"><br /> 
	  <td>Takt Time</td>
	  <input type="text" name="tt" size="5"><br />
	  <td>Downtime</td>
	  <input type="text" name="downtime" size="5"><br />
	  
 	  <input type="submit" name="doit" value="calculate">
 	 </form>
 	 ';
 	 }else{
 	  if($_POST['day'] == 'mon')
 	  {
 	   echo 'Your working hour is 495min';
	   $result=495 - $downtime;
	   availability($result);
	   performance($not, $tt, $av, $result);
	   quality($no, $av);
	   oee($count2, $count4, $count7);
	   }
	   
 	  if($_POST['day'] == 'tue')
 	  {
	   echo 'Your working hour is 505min';
 	   $result=505 - $downtime;
	   availability($result);
	   performance($not, $tt, $av, $result);
	   quality($no, $av);
	   oee($count2, $count4, $count7);
 	  }
	  
 	  if($_POST['day'] == 'wed')
 	  {
	   echo 'Your working hour is 505min';
	   $result=505 - $downtime;
	   availability($result);
	   performance($not, $tt, $av, $result);
	   quality($no, $av);
	   oee($count2, $count4, $count7);
 	  }
	  
 	  if($_POST['day'] == 'thu')
 	  {
 	   echo 'Your working hour is 505min';
	   $result=505 - $downtime;
	   availability($result);
	   performance($not, $tt, $av, $result);
	   quality($no, $av);
	   oee($count2, $count4, $count7);
 	  }
	  
 	  if($_POST['day'] == 'fri')
 	  {
 	   echo 'Your working hour is 430min';
	   $result=430-$downtime;
	   availability($result);
	   performance($not, $tt, $av, $result);
	   quality($no, $av);
	   oee($count2, $count4, $count7);
 	  }
	 }
	 
function availability($result){
$count2= $result / $ppt;
$count3= $count2 * 100;
$count = number_format($count3, 0);
echo 'Availability percentage is'. "$count" . "%";
}

function performance($not, $tt, $av, $result){
$not   = $av / $result;
$count4= $not / $tt;
$count5= $count4 * 100;
$count6= number_format($count5, 0);
echo 'Performance percentage is'. "$count6" . "%";
}

function quality($no, $av){
$count7= $no / $av;
$count8= $count7 * 100;
$count9= number_format($count8, 0);
echo 'Quality percentage is'. "$count9" . "%";
}

function oee($count2, $count4, $count7){
$count10= $count2 * $count4 * $count7;
$count11= $count10 * 100;
$count12= number_format($count11, 0);
echo 'OEE percentage is'. "$count12" . "%";
}
	 
	 
	 
	 
	 
	 
	 
	 ?>





Reply to this topic


This post will need approval from a moderator before this post is shown.

  


1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users