www.webdeveloper.com
Results 1 to 2 of 2

Thread: My Home Calculator

  1. #1
    Join Date
    Jun 2011
    Posts
    20

    Post My Home Calculator

    How can make a programme in php for calculating total energy used in my home with out using the database.in this case, i Submit the values by HTML in form of Radio Buttons.I can select
    25 watt energy saver bulb, 15 watt or 60 watt.
    there are 5 places at which bulbs are fitted.

    If I use 12 hours daily all five bulbs of 25 watt.
    what will be total energy I used in one Month.

    If I use 12 hours daily all five bulbs of 15 watt.
    what will be total energy I used in one Month.

    If I use 12 hours daily all five bulbs of 60 watt.
    what will be total energy I used in one Month.

    If I used 15 watt bulb. how much i can save energy.
    thanks.
    I m waiting for ur reply

  2. #2
    Join Date
    Feb 2012
    Location
    Tallahassee, FL
    Posts
    280
    Here it is in the simplest form.

    PHP Code:
    <?
    if(isset($_POST['submit'])){
        
    $type $_POST['type'];
        
    $amount $_POST['amount'];
        
    $total 12*$type*$amount;
        
    $lowest 12*15*$amount;
        
    $save $total-$lowest;
    }
    ?>
    <html>
    <head>
    <title>Energy Calc</title>
    </head>
    <body>
    <?
    if(isset($save)){
        echo 
    "<table>";
        echo 
    "<tr><td>You are using $amount $type watt bulbs.  This is $total watts in a 12hr time frame.</td></tr>";
        if(
    $type != 15){
            echo 
    "<tr><td>If you used 15 watt bulbs, you would only be using $lowest watts!  That is a $save watt difference!</td></tr>";
        }
        echo 
    "</table>";
    }
    ?>
    <form method="post">
    <table>
    <tr><td colspan="2">What type of bulb do you have?</td></tr>
    <tr><td colspan="2"><input type="radio" name="type" value="25" />25 Watt Energy Saver&nbsp;|&nbsp;<input type="radio" name="type" value="15" />15 Watt&nbsp;|&nbsp;<input type="radio" name="type" value="60" />60 Watt</td></tr>
    <tr><td align="right"> How Many?</td><td><input id="amount" type="text" name="amount" /></td></tr>
    <tr><td colspan="2" align="center"><input type="submit" name="submit" id="submit" />
    </table>
    </form>
    </body>
    </head>

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles