Hi People.
I run a website for microlight (ultralight pilots) and I have had written a PHP script for adding up times in a logbook.
Please can someone spell out how I put it into a widget because I've just tried to configure one and it shows nothing in the page once enabled. Here is the code for the calculator.
Please can you tell me what I need to do inside a widget to get it to work. I simply pasted the code below but that's obviously not right seeing that it doesn't work.
On behalf of all the members, thanks in advance.
I run a website for microlight (ultralight pilots) and I have had written a PHP script for adding up times in a logbook.
Please can someone spell out how I put it into a widget because I've just tried to configure one and it shows nothing in the page once enabled. Here is the code for the calculator.
Please can you tell me what I need to do inside a widget to get it to work. I simply pasted the code below but that's obviously not right seeing that it doesn't work.
On behalf of all the members, thanks in advance.
PHP Code:
<?php
/*
Name: Add Times Calculator
URI: http://dynainternet.com/logged.php
Description: Add multiple hours and minutes using whole or decimal numbers
Version: 2.4
Author: Jay Przekop (aka:Quick)
Author URI: http://dynainternet.com
License: GPL
*/
$hours = $_POST['hour'];
$minutes = $_POST['minute'];
if($hours != '' || $minutes != '') {
$allhours = array_sum(array_filter($hours));
$explode_hours = explode(".",$allhours);
$collect_hours = $explode_hours['0'];
$collect_hours_decimal = $explode_hours['1'];
$collect_hours_decimal = substr(round($collect_hours_decimal,2),0,2);
if ($collect_hours_decimal != '') {
if(strlen($collect_hours_decimal) <= 1){
$collect_hours_decimal = $collect_hours_decimal *10;
}
$hours_dec_convert_minutes = substr($collect_hours_decimal*60/100,0,2);
} else {
$hours_dec_convert_minutes = 00;
}
$allminutes = array_sum(array_filter($minutes));
$explode_minutes = explode(".",$allminutes);
$collect_minutes_zero = $explode_minutes['0'];
$collect_minutes_one = $explode_minutes['1'];
$explode_seconds = explode(".",$collect_minutes_one);
$collect_seconds_zero = $explode_seconds['0'];
if($collect_seconds_zero != ''){
if(strlen($collect_seconds_zero) <= 1){
$collect_seconds_zero = $collect_seconds_zero *10;
}
$seconds_dec_convert_seconds = substr($collect_seconds_zero * 60/100,0,2);
} else {
$seconds_dec_convert_seconds = $collect_seconds_zero;
}
$collect_minutes_one = $seconds_dec_convert_seconds + $collect_minutes_one;
if($collect_minutes_one != ''){
if(strlen($collect_minutes_one) <= 1){
$collect_minutes_one = $collect_minutes_one *10;
}
$minutes_dec_convert_minutes = substr($collect_minutes_one*60/100,0,2);
} else {
$minutes_dec_convert_minutes = $collect_minutes_one;
}
$add_allminutes = $hours_dec_convert_minutes + $collect_minutes_zero;
$hoursfromminutes = floor($add_allminutes / 60);
$deduct_amount = 60 * $hoursfromminutes;
$totalminutes = $add_allminutes - $deduct_amount;
$totalhours = $collect_hours + $hoursfromminutes;
}
?>
<!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>Add Times Calculator</title>
</head>
<body>
<h1>Logbook Calculator</h1><br />
Put your figures into the boxes and click the Add button.<br />
Now works if you put 0.75 into an hour box it adds it as 45 minutes.
<form action="" method="post" enctype="multipart/form-data">
<table style="color: #000000; font-family: Verdana; font-weight: bold; font-size: 12px; background-color: #c7f6d2;" width="501" border="1" cellspacing="5" cellpadding="5">
<?php
//set this for how many input fields you want
$how_many_fields = 12;
$input_field_array = range(0,$how_many_fields -1);
foreach ($input_field_array as $input_number) {
echo "<tr>
<td width='150'>
<input type='int' name='hour[]' value='$hours[$input_number]' size='20' maxlength='10' />
Hrs</td>
<td width='150'>
<input type='int' name='minute[]' value='$minutes[$input_number]' size='20' maxlength='10' />
Mins</td>
</tr>
<tr>";
}
?>
<tr>
<td><input style="height: 50px; width: 100px; color: #000000; font-family: Verdana; font-weight: bold; font-size: 12px; background-color: #34f325;" size="15" type="submit" name="submit" value="Add" /> <input type="button" style="height: 50px; width: 100px; color: #000000; font-family: Verdana; font-weight: bold; font-size: 12px; background-color: #87f87e;" size="100" value="Reset" onClick="location.href='<?php echo filter_var($_SERVER["SCRIPT_NAME"], FILTER_SANITIZE_STRING);?>'"></td>
<td><input value="<?php echo $totalhours;?>" type="int" size="20" maxlength="10" />
Hrs
<input type="int" value="<?php echo $totalminutes;?>" size="20" maxlength="10" />
Mins</td>
</tr>
</table>
<tr></tr>
</form>
</body>
</html>
<!--/*<?php highlight_file('logged.php');?>*/ -->
Comment