www.webdeveloper.com
Results 1 to 4 of 4

Thread: [RESOLVED] unknown variable

  1. #1
    Join Date
    Jun 2011
    Location
    California
    Posts
    383

    resolved [RESOLVED] unknown variable

    On the how many input box in red, I'm going to allow a user to enter any specific number... based on that number it needs to calculate whatever the $seconds variable is equal too at the time. Than the output should echo the seconds, minutes, hours fields. I hope that makes sense... Any help would be greatly appreciated. Thanks in advance.

    PHP Code:

    $results = sql::clean_row("
        select
        sum(quantity) as quantity,
        (sum(duration_minutes) * 60) + sum(duration_seconds) as duration_seconds
    from event.dbo.process_data
    where process_id=$process_id");

    //echo $results['duration_minutes'] . " " . $results['duration_seconds'] . " " . $results['quantity'] . "<br />";

    $seconds = floor($results['duration_seconds'] / $results['quantity']);
    $minutes = $seconds/60;

     
    echo "<br />Quantity  " . $results['quantity']. "&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;  time in seconds ($seconds) / 60 = total time in minutes ($minutes)";

    <table>
    <form action="<?php echo matry::here(array('page'=> 'cal')); ?>" method="POST">    
    <tr><td><?php inp('how_many'); ?></td><td> * <?php echo $seconds?></td></tr>
    <tr><td>This many Seconds:</td></tr> 
    <tr><td>This many Minutes:</td></tr>
    <tr><td>This many Hours:</td></tr>
    <tr><td>This many FTE:</td></tr>
    <tr><td><input type="submit" value="Calculate" name="submit" /></td></tr>
    </form>
    </table>
    Last edited by Supplement; 11-06-2012 at 05:56 PM.

  2. #2
    Join Date
    Jun 2011
    Location
    California
    Posts
    383
    I guess it would probably help if I actually added a form action and a submit button.

    Help please.

  3. #3
    Join Date
    Jun 2011
    Location
    California
    Posts
    383
    This is what i got so far... but how do i assign the 'how_man' input box to multiply against the $seconds variable based on whatever is input in the 'how_many' input box? I hope this makes sense.. i need help. thanks in advance.

    PHP Code:
    <table>
    <form name="calc" action="<?php echo matry::here(array('page'=> 'calc')); ?>" method="POST"> 
    <tr><td><?php inp('how_many'); ?></td><td> * <?php echo $seconds?></td></tr>
    <tr><td>This many Seconds:</td></tr> <?php echo $result?>
    <tr><td>This many Minutes:</td></tr>
    <tr><td>This many Hours:</td></tr>
    <tr><td>This many FTE:</td></tr>
    <tr><td><input type="submit" value="Calc" name="submit" /></td></tr>
    </form> 
    </table>


    <?php 

    $page 
    $_GET['calc']; 

    // Defining the "calc" class 
    class calc 
         var 
    $how_many
         var 
    $seconds

      

              function 
    multiply($how_many,$seconds
              { 
                       
    $result =$how_many $seconds
                        echo(
    "The product of $how_many and $seconds is $result<br><br>"); 
                        echo(
    "$how_many x $seconds = $result"); 
                        exit; 
               } 

    $calc = new calc(); 


    foreach(
    $how_many['how_many'] as $result) {
        echo 
    $result['seconds'], '<br>';
    }

    ?> 

     


    <?php 
    if($page == "calc"){ 
    $how_many $_POST['how_many']; 
    $seconds $_POST['seconds']; 

        if(
    $oper == "multiply"){ 
              
    $calc->multiply($how_many,$seconds); 
         } 

    ?>

  4. #4
    Join Date
    Jun 2011
    Location
    California
    Posts
    383

    Lightbulb

    I'm still looking for help.

    Trying to get whatever number is input * the variable $seconds

    Thanks in advance.

Thread Information

Users Browsing this Thread

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

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