+ Reply to Thread
Results 1 to 8 of 8

Thread: [100c]Simple equation page

  1. #1
    0010111 is offline x10Hosting Member 0010111 is an unknown quantity at this point
    Join Date
    Jul 2008
    Posts
    58

    [100c]Simple equation page

    this image should explain it.

    input is how the page should look and the equation is well... how the input should be used. HTML/JS is prefered, PHP is you must. 15c if you tried. 100c for the one i like.
    Last edited by 0010111; 12-07-2008 at 08:18 PM.




  2. #2
    diabolo's Avatar
    diabolo is offline Community Advocate diabolo is on a distinguished road
    Join Date
    Nov 2007
    Location
    Jersey Shore
    Posts
    1,683

    re: [100c]Simple equation page

    well since I don't know where you are getting the input from, I'll just create those variables.

    PHP Code:
    <?php
    //Define Variables
    $fileSize "";
    $uploaded "";
    $downloaded "";
    $finalRatio "0";

    //Math
    $totalDown $fileSize $downloaded;
    $finalRatio $uploaded $totalDown;

    //Displays the values (optional)
    echo $totalDown;
    echo 
    "<br />";
    echo 
    $finalRatio;
    ?>

  3. #3
    0010111 is offline x10Hosting Member 0010111 is an unknown quantity at this point
    Join Date
    Jul 2008
    Posts
    58

    re: [100c]Simple equation page

    Quote Originally Posted by diabolo View Post
    well since I don't know where you are getting the input from, I'll just create those variables.

    PHP Code:
    <?php
    //Define Variables
    $fileSize "";
    $uploaded "";
    $downloaded "";
    $finalRatio "0";

    //Math
    $totalDown $fileSize $downloaded;
    $finalRatio $uploaded $totalDown;

    //Displays the values (optional)
    echo $totalDown;
    echo 
    "<br />";
    echo 
    $finalRatio;
    ?>
    i keep getting this:
    Warning: Division by zero in /home/o111011/public_html/r/equation.php on line 10

    i changed "
    $finalRatio = "0";" to "$finalRatio = "1";" but that made no difference.

    also, i was hoping the user would input the data. hence '[input]'
    Last edited by 0010111; 12-09-2008 at 06:21 PM.




  4. #4
    diabolo's Avatar
    diabolo is offline Community Advocate diabolo is on a distinguished road
    Join Date
    Nov 2007
    Location
    Jersey Shore
    Posts
    1,683

    re: [100c]Simple equation page

    PHP Code:
    <?php
    if(isset($_POST) {
    //Define Variables
    $fileSize "$_POST['fileSize']";
    $uploaded "$_POST['uploaded']";
    $downloaded "$_POST['downloaded']";
    $finalRatio "1";

    //Math
    $totalDown $fileSize $downloaded;
    $finalRatio $uploaded $totalDown;

    //Displays the values (optional)
    echo $totalDown;
    echo 
    "<br />";
    echo 
    $finalRatio;
    }
    ?>
    HTML Code:
    <form action="index.php" method="post">
    File Size:  <input type="text" name="fileSize" />
    Uploaded: <input type="text" name="uploaded" />
    Downloaded: <input type="text" name="downloaded" />
    <input type="submit" value="Submit" />
    <input type="hidden" name="action" value="login" />
    </form>
    here is what I came up with, save it as a .php and make sure the form redirects to itself; also this does not prevent users from placing in an alphabetical character, therefor the equation will screw up; but rite now I'm too lazy to implement one
    Last edited by diabolo; 12-09-2008 at 06:37 PM.

  5. #5
    0010111 is offline x10Hosting Member 0010111 is an unknown quantity at this point
    Join Date
    Jul 2008
    Posts
    58

    Re: [100c]Simple equation page

    @Diabolo: the html works fine, correct me if i am wrong but it measures in MB ? can it identify MB/GB/TB ? also:
    Parse error: syntax error, unexpected T_VARIABLE in /home/o111011/public_html/r/eq.php on line 4
    code hasn't changed.




  6. #6
    diabolo's Avatar
    diabolo is offline Community Advocate diabolo is on a distinguished road
    Join Date
    Nov 2007
    Location
    Jersey Shore
    Posts
    1,683

    Re: [100c]Simple equation page

    the script doesn't define what it measures it in; you can interpret it any way you want; ie
    if you want it as bytes

    the would put 100 bytes for 1 MB, I think

  7. #7
    tttony's Avatar
    tttony is offline x10 Sophmore tttony is an unknown quantity at this point
    Join Date
    Jan 2008
    Location
    ~ 10°10'27.10''' N 67°59'59'.59''' O elev. 457m
    Posts
    147

    Re: [100c]Simple equation page

    just one tip:

    dont use variables into double quotes:

    PHP Code:
    $fileSize "$_POST['fileSize']";
    $uploaded "$_POST['uploaded']";
    $downloaded "$_POST['downloaded']";
    $finalRatio "1"
    like this its better:

    PHP Code:
    $fileSize $_POST['fileSize'];
    $uploaded $_POST['uploaded'];
    $downloaded $_POST['downloaded'];
    $finalRatio 1// <-- now its evaluate as integer 
    PHP & MySQL Web Developer
    Free Domain co.cc

  8. #8
    diabolo's Avatar
    diabolo is offline Community Advocate diabolo is on a distinguished road
    Join Date
    Nov 2007
    Location
    Jersey Shore
    Posts
    1,683

    Re: [100c]Simple equation page

    thank you tttony
    Edit:
    <?php
    //Define Math Function
    function doMath($fileSize, $uploaded, $downloaded) {
    $totalDown = $fileSize + $downloaded;
    $finalRatio = $uploaded / $totalDown;
    }

    if(isset($_POST) {
    //Define Variables
    $fileSize = $_POST['fileSize'];
    $uploaded = $_POST['uploaded'];
    $downloaded = $_POST['downloaded'];
    $finalRatio = 1;

    //Checks
    if(is_numeric($fileSize) == FALSE){
    $error = "Please enter a numeric value for File Size.";
    }
    if(is_numeric($uploaded) == FALSE){
    $error = "Please enter a numeric value for Uploaded.";
    }
    if(is_numeric($downloaded) == FALSE){
    $error = "Please enter a numeric value for Downloaded.";
    }
    if((isset($_POST) AND (is_numeric($downloaded)){
    doMath($fileSize, $uploaded, $downloaded);
    }

    //Displays the values (optional)
    echo $totalDown;
    echo "<br />";
    echo $finalRatio;
    }
    ?>

    <form action="index.php" method="post"> <!-- this is index.php -->
    File Size: <input type="text" name="fileSize" />
    Uploaded: <input type="text" name="uploaded" />
    Downloaded: <input type="text" name="downloaded" />
    <input type="submit" value="Submit" />
    <input type="hidden" name="action" value="login" />
    </form>



    not fully done, few bugs but busy
    Last edited by diabolo; 12-12-2008 at 03:00 PM. Reason: Automerged Doublepost

+ Reply to Thread

Similar Threads

  1. [REQ][$$$]1 page image flash redesign for choclate sales
    By tgkprog in forum The Marketplace
    Replies: 5
    Last Post: 11-17-2008, 09:53 AM
  2. Use PHP to add Content to page through Admin
    By goldy30 in forum Programming Help
    Replies: 1
    Last Post: 11-12-2008, 11:13 PM
  3. Unique php page
    By bunglebrown in forum Programming Help
    Replies: 48
    Last Post: 11-08-2008, 08:59 AM
  4. Replies: 0
    Last Post: 10-19-2008, 09:40 PM
  5. Passing variables from page to page
    By os242 in forum Scripts & 3rd Party Apps
    Replies: 3
    Last Post: 09-15-2007, 02:05 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers