Jump to content

Search the Community

Showing results for tags 'math'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 11 results

  1. Is there any function in php lib that does the following $a = 1238; $n = 48; // 1*2*3*8 or I will have to create one for my script? (I want to do it for both client and server sides based on request sent by user. I actually want it in php that is why i asked it here, but if the solution (as function) is available in javascript (not jQuery) please share or guide me.)
  2. php 5.5.42 Database name: forums Table name: phpbb_users Row name: user_id What SQL query can I run in phpMyAdmin to update the user_id in every row, adding 8447002 to each user_id?
  3. Hey guys, I need some help with a simple script a friend wrote for me but isn't returning the correct values. I'm looking to get this script working but my PHP skills are abysmal and I can't for the life of me figure out whats the best way to do this. I've tried contacting my friend but he's moving cross-country so I'm hoping you guys can give me some advice. The script is supposed to return a total shipping price based on the weight of products that are passed to it via an API and the location of the visitor. There are a total of 3 different products (Product A, Product B, Product C) each with it's own weight in grams and it's own shipping rate. The script is needs to follow the following rules: When 1 product (either Product A, B, or C) is in the cart it returns the full fixed shipping price for either US or International Shipping based on $isInternational When 2 or more of Product A or B are added to the cart the full shipping is taken for the heaviest item and a fixed price is added for each additional item (Product and B each have their own fixed prices) When Product C is added to the cart it returns a fixed based on US or International (Product C ships separately and doesn't depend on the weight/prices of Product A or B) The product weights/prices are: Product A: Weight (grams): 250 Us Shipping for first instance: $6.00 International Shipping for first instance: $10.00 Each additional instance: $1.00 Product B: Weight (grams): 300 Us Shipping for first instance: $8.00 International Shipping for first instance: $11.00 Each additional instance: $2.50 Product C: Weight (grams): 120 Us Shipping for each instance: $8.00 International Shipping for each instance: $20.00 An example would be if the cart contained 2 of Product B, 1 of Product A, and 2 of Product C shipping to the US: The price would be 8+2.50+1+8+8=27.50 The script currently ignores the addition of more instances of the items and doesn't take into account US vs International: <? header('Content-Type: application/json'); $json = file_get_contents('php://input'); $request_body = json_decode($json, true); if (is_null($request_body) or !isset($request_body['eventName'])) { header('HTTP/1.1 400 Bad Request'); $response = array( "rates" => "" ); die(json_encode($response)); } switch ($request_body['eventName']) { case 'shippingrates.fetch': // ============= recieve data from cart ============== $country_code = $request_body["content"]["billingAddressCountry"]; $state_code = $request_body["content"]["billingAddressProvince"]; $isInternational = ($country_code != "US"); $quantity = 0; $maxWeight = 0; $cost = 0; $description = "International Shipping"; if($request_body["content"] && $request_body["content"]["items"]){ foreach ($request_body["content"]["items"] as $cart_item){ $quantity += $cart_item["quantity"]; if($cart_item["weight"] >= 300){ $cost += 2.50; } else if($cart_item["weight"] >= 200){ $cost += 1.0; } else if($cart_item >= 100){ $cost += ($isInternational)? 15.0 : 8.0; } if($cart_item["weight"] > $maxWeight){ $maxWeight = $cart_item["weight"]; } } } if($maxWeight >= 300) { $cost += ($isInternational) ? 11.0 : 8.0; $cost -= 2.50; } else if ($maxWeight >= 200) { $cost += ($isInternational) ? 10.0 : 6.0; $cost -= 1; } if($isInternational){ $description = "International Shipping"; } else { $description = "USPS Standard Shipping"; } // =========== return data to cart =============== $rates = array( array( "cost" => $cost, "description" => $description ), ); $response = array( "rates" => $rates ); header('HTTP/1.1 200 OK'); echo(json_encode($response)); break; default: header('HTTP/1.1 200 OK'); break; } ?> Thanks for any help you guys can give!
  4. Given the following code: updateTotal: function () { var total = 0; $('input#itemLineTotal').each(function (i) { price = $(this).val().replace("$", ""); if (!isNaN(price)) total += Number(price); }); $('#subTotal').html("$" + this.roundNumber(total, 2)); var grdTotal = total + this.updateSalesTax(); grdTotal = this.roundNumber(grdTotal, 2); $('#grandTotalTop, #grandTotal').html("$" + grdTotal); }, updateSalesTax: function () { var total = 0; $('input#itemLineTotal').each(function (i) { price = $(this).val().replace("$", ""); if (!isNaN(price)) total += Number(price); }); var tax = $("#tax").val(); $("#salesTax").html("$" + mioInvoice.roundNumber(tax, 2)); return tax; }, How can add the tax to the total to give the grand total. Please help
  5. Hello I got a question , Im trying to add balance after each transaction ,what I tried to do is to echo $account Balance and then use function to deduct the row amount Im really confused and can't figure it out how i would i achieve such thing : The code I've used <td>£ <?php echo number_format ($account['balance'] + $row['amount'], 2); ?></td>
  6. Hi! I'm making a time laps calculator based off of the equation found http://americandslr.com/2010/10/time-lapse-calculator/ there. I'm completely done with the functional part of it. Now I need to worry about the aesthetic part of it. Here is the code: <?php if (isset($_POST['filming'])) $hour = $_POST['filming']; if (isset($_POST['framerate'])) $framerate = $_POST['framerate']; if (isset($_POST['dtrt'])) $dtrt = $_POST['dtrt']; $half = $hour * 3600; $halftwo = $framerate * $dtrt; $answer = $half / $halftwo; ?> <!DOCTYPE html> <html lang='en'> <head> <title>Timelapse Calculator</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <!-- Bootstrap --> <link href="css/bootstrap.min.css" rel="stylesheet" media="screen"> </head> <body> <div class="well span 5"> <form class="form-horizontal" method="POST"> <fieldset> <!-- Form Name --> <legend><h1><center>Timelapse Calculator</h1></center><br></legend> <!-- Text input--> <div class="control-group"> <label class="control-label" for="filming"><strong>Film Time (in hours)</strong></label> <div class="controls"> <input id="filming" name="filming" type="text" placeholder="type here..." class="input-medium" required=""> <p class="help-block">1 hour would be "1", 1 and a half hours would be "1.5" etc. </p> </div> </div> <!-- Text input--> <div class="control-group"> <label class="control-label" for="framerate"><strong>Frame Rate</strong></label> <div class="controls"> <input id="framerate" name="framerate" type="text" placeholder="type here..." class="input-medium" required=""> <p class="help-block">How fast will it be presented?</p> </div> </div> <!-- Text input--> <div class="control-group"> <label class="control-label" for="dtrt"><strong>Duration</strong></label> <div class="controls"> <input id="dtrt" name="dtrt" type="text" placeholder="type here..." class="input-medium" required=""> <p class="help-block">How long do you want the time lapse to last? <u>IN SECONDS</u></p> </div> </div> <!-- Button --> <div class="control-group"> <label class="control-label" for="submit"></label> <div class="controls"> <input type="submit" class="btn btn-primary btn-large" value="Submit"/> </div> </div> </fieldset> </form> <h2><center><strong><?php echo $answer . " seconds between picture" ?></center></strong></h2> </div> <script src="http://code.jquery.com/jquery.js"></script> <script src="js/bootstrap.min.js"></script> </body> </html> (yes i'm using bootstrap) Here is a screenshot of what it looks like before and after you submit: Before submission: http://gyazo.com/361d109f0af010fcda4d90288b338566 After submission: http://gyazo.com/cf1c2c2089af3f6b4bf349aeab7fc1d4 1. how do I make it round to the nearest tenth? When I used "round($answer, 1);" it crashed my script. 2. How can I make the "seconds between picture" only appear after you press submit? Thanks, I'm a noob. Fisher
  7. I recently filled out a job application for a web developer position. In addition to the usual 'tell us about yourself' questions, I was presented with this one. After searching the web and hacking at it for nearly an hour. I just punched in 5. I'm sure it's wrong. Anyway, I was wondering if someone could give me some clarification on what is happening here: <?php /* What value should you replace the '?' with to make the output read 10? */ var x = 6; var y = 4; var a = function(b) { return function© { return y + b + c; } }; x = 2; y = 5; var fn = a(x); x = 1; y = 3; var unknown = ?; console.log(fn(unknown));* ?> Am I reading correctly that the value of var a is equal to the value returned by function(b) which is equal to the value returned by function© which is y + b + c? I concluded that the value of var a = 4 + 2b + 2c. But since var b and var c are not defined how would I go about getting a strictly numeric value as output? Pardon my ignorance, but I have faced questions like this for other job apps and I am tired of staring at the screen like an idiot! Any clarification would be greatly appreciated!
  8. Hello, I not to confident with arrays but I'm sure one could be used instead of all the code I've written below. Any help or direction is appreciated. My database records have unique id's. Each id has a frequency in days in which they are due on a repeating basis. I would like to limit the amount of due dates displayed. Currently I am showing 8. Is is possible to limit the due dates shown based on a future date? Example: Show tasks due within the next 100 days. Some tasks with shorter frequencies(10 days) would show 10 due dates but tasks with say a 90 day frequency would only show one date. Here is what I have come up with so far: // Get all the data from the "mss" table $result = mysql_query("SELECT * FROM mss ORDER BY id ASC") or die(mysql_error()); while($row = mysql_fetch_array($result)){ // Calculates when the task is next due // If there is a last completion date then show next due date from this completion date. $calc_date = $row['last_completed']; //If there is no date for last_completion, then use the start_date to find next due date if ($calc_date == '0000-00-00') { $calc_date = $row['start_date']; } $due = date('F d, Y', strtotime($calc_date .' + '.$row['frequency'].' days')); $due2 = date('F d, Y', strtotime($due .' + '.$row['frequency'].' days')); $due3 = date('F d, Y', strtotime($due2 .' + '.$row['frequency'].' days')); $due4 = date('F d, Y', strtotime($due3 .' + '.$row['frequency'].' days')); $due5 = date('F d, Y', strtotime($due4 .' + '.$row['frequency'].' days')); $due6 = date('F d, Y', strtotime($due5 .' + '.$row['frequency'].' days')); $due7 = date('F d, Y', strtotime($due6 .' + '.$row['frequency'].' days')); $due8 = date('F d, Y', strtotime($due7 .' + '.$row['frequency'].' days')); $line = $row['id']. " - <strong>Next Due Dates: ". $due ." | ". $due2 ." | ". $due3 ." | ". $due4 ." | ". $due5 ." | ". $due6 ." | ". $due7 ." | ". $due8 ."</strong> <br/><br/>"; echo "$line"; } ?> Thanks John
  9. hello every one... I want to have something similar like this in php that calculate the difference between dates ... date format = d/m/yyyy date1 = 8/5/13 date2 = 5/7/13 how to calculate the difference between the two dates in days.... Any help.....
  10. Hi, I don't know what i am doing wrong. I have two php files, Page1.php has a summation ($Profit 2012) and i want to import the result of that variable into a Page2.php. Page1.php <?PHP $Gain2012 = 500; $Loss2012 = 200; $Profit2012 = $Gain2012 - $Loss2012; ?> Page2.php <?PHP $Profit2012 = ob_start(); include 'Page1.php'; ob_end_clean(); $Profit; $Gain2013 = 100; $Loss2013 = 50; $Profit2013 = $Gain2013 - $Loss2013; $ProfitSum = $Profit2012 + $Profit2013; ?> As output for $Profit2012 in Page2.php, i get the data 1 instead of 300.
  11. I have a php script that looks at a supplier website and queries from a pricing calculator, the script displays the result in a table. The result is my actual cost from my supplier and the price is displayed as a string. I need to convert my wholesale cost from a string to a value and then add my retail markup cost then display the Retail Cost as a string in my table. Unfortunately, I am a complete newbie and have been searching various methods, but no matter what I try, it fails. Here is the script: <?php // Request parameters $materialid = $_GET['materialid']; $sizeid = $_GET['sizeid']; $quantity = $_GET['quantity']; $numcolors = $_GET['numcolors']; // form URL for request //$url = "http://www.suppliersite.com/pricing?materialid=104&sizeid=37&quantity=1&numcolors=1"; $url = "http://www.suppliersite.com/pricing?materialid=".$materialid."&sizeid=".$sizeid."&quantity=".$quantity."&numcolors=".$numcolors; // Create DOM from URL or file $html = file_get_html($url); // Echo page //echo $html->plaintext; $price_per_item = $html->find('#price-per-item'); $total_price = $html->find('#total-price'); $description = $html->find('.description'); $name = $html->find('h3'); //echo $price_per_item[0]."<br />"; //echo $total_price[0]."<br />"; //echo $description[0]."<br />"; //echo $name[1]."<br />"; // Iterate through all combinations: echo "<table id=\"products\">"; echo "<tr>"; //echo "<th>Price per item</th><th>Total Price</th><th>Product</th><th>Description</th><th>Size</th><th>Quantity</th>"; echo "<th width=\"25%\">Price per item</th><th width=\"15%\">Total Price</th><th width=\"30%\">Product</th><th width=\"10%\">Size</th><th width=\"10%\">Colors</th>"; echo "<tr>"; $price_per_item = $html->find('#price-per-item'); $total_price = $html->find('#total-price'); $description = $html->find('.description'); $size = $html->find('select[id='.'top-sizes-select'.'] option[value='.$sizeid.']'); echo"<tr>"; echo "<td>".$price_per_item[0]."</td>". "<td>".$total_price[0]."</td>". "<td>".$name[1]->innertext."</td>". // "<td>".$description[0]."</td>". "<td>".$size[0]->innertext."</td>". "<td>".$numcolors."</td>"; echo "</table>"; echo "<br />"; echo "<div style=\"width:40%\">"; echo $description[0]; echo "</div>"; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-GB"> <head> <title>Extractor</title> <style media="screen" type="text/css"> #products { font-family:Arial, Helvetica, sans-serif; width:60%; border-collapse:collapse; font-size:12px; } #products td, #products th { font-size:1em; border:1px solid #777777; padding:3px 7px 2px 7px; } #products th { font-size:1.1em; text-align:left; padding-top:5px; padding-bottom:4px; background-color:#777777; color:#ffffff; } </style> </head> <body> </body> </html> Attached is a screenprint of the results, you will see the cost per item is $11.55 and I simply want to add 20% or as in the code: = price-per-item*1.2 -----so the price should show $13.86 per item I have tried to define a value such as: $RETAIL_price_per_item = $html->find(int('#price-per-item')*1.2); but that does not work I have tried many other versions and in different areas of the code but nothing works. Any help would be greatly appreciated. Thanks
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.