PHP - Php Estimate Cost Formula
Similar TutorialsI need to know if there is any standard to estimate the effort to create a page in Java vs PHP.
For example, if we need to build a login page. I understand there are many factors but trying to see if there is any standards to compare these 2 technology in terms of effort
These are the specs that come to mind, CPU, RAM, Storage, Bandwith
My question is this, once you know what the point of a website is, whether it is to host videos, design something with an editor, ecommerce, if I ask a costumer "How many people do you expect to be on your site?"
Is that a fair question? Or is that arbitrary or even rhetorical like "Duh... the maximum count"
I want to know based on what is being accessed whether it is the photos displayed on page, character count, flash / javascript, whatever... how can I estimate?
This is for assigning VPS's depending on the clients requirement
I'm looking at shared hosting provided by GoDaddy. On the shared hosting they offer, entry process limitations range from 100 to 125.
I was also told this by customer support:
Entry Processes are the number of connections your account can process simultaneously. Understanding what constitutes a connection is important, though, because it's not as straightforward as "the number of visitors on your website." Here's what constitutes as a connection: Your website delivering data via HTTP Your hosting account transferring data via SSH A Cron job processing However, the connections are only counted while they're processing. As soon as they've finished, they no longer count as processes. For an example, if a visitor comes to your site and your home page takes .1 seconds to load and generates only one HTTP connection, that visitor counted as one process for .1 seconds. Even though that visitor is still "viewing your site," they no longer count as a connection until they do something else that generates another connection, like move to a new page. So what is an average user count that I can conclude? I don't want to think that "it's not possible" I just need to know what limitations I'm looking at. I'm also curious what kind of error would be generated if more than 100 or 125 people tried to access the server simulataneously. Or perhaps employ an access delay of some sort. Edited by moose-en-a-gant, 10 January 2015 - 09:59 PM. This code, that I didn't write, but am trying to modify, generates the cost of a video purchase. One line (line 32) is a formula , I believe for setting a purchase price amount: $amout += $video->video_play_price?$video->video_play_price:$video_cost; Another line (line 50) is a formula for deducting to create another amount: $uploader_amount = $video_cost - $charge; I think line 50 is correct except for I don't think $video_cost in the final price, but I'm no expert at reading this code. I tried this without success: $uploader_amount = $video_play_price - $charge;
Here is the full code, any help with line 50, will be appreciated. <?php if (IS_LOGGED == false) { $data = array('status' => 400, 'error' => 'Not logged in'); echo json_encode($data); exit(); } if (!empty($_POST['id'])) { if (!is_array($_POST['id'])) { $id_array[] = $_POST['id']; } else { $id_array = $_POST['id']; } // get cost video $db->where('name', 'video_play_price'); $db_cost = $db->getOne('config'); $video_cost = (float)$db_cost->value; $count_video = count($id_array); $user_id = $user->id; $wallet = (float)str_replace(',', '', $user->wallet); $amout = 0; foreach ($id_array as $id) { $video_id = (int)PT_Secure($id); // get video data $video = $db->where('id', $id)->getOne(T_VIDEOS); $amout += $video->video_play_price?$video->video_play_price:$video_cost; } // $amout = $video_cost * $count_video; $charge = ( $video_cost *0.50 ); if ($wallet >= $amout) { $new_wallet = (string)($wallet - $amout); $db->startTransaction(); $inserted_records = 0; foreach ($id_array as $id) { $video_id = (int)PT_Secure($id); $uploader_amount = $video_cost - $charge; // get video data $video = $db->where('id', $id)->getOne(T_VIDEOS); // add data to paid table $insert_buy = $db->insert('u_paid_videos', [ 'id_user' => $user_id, 'id_video' => $video_id, 'session_key' => $_SESSION['session_key'], 'video_play_price' => (string)$video_cost, 'video_title' => $video->title, 'user_id_uploaded' => $video->user_id, //'up_credit'=>$video_cost, 'up_credit'=>$uploader_amount, ]); if ($insert_buy) { $inserted_records++; } //add wallet users' video $userwallet = $db->where('id', $video->user_id)->getOne(T_USERS); //$videouserwallet = $userwallet->wallet+$video_cost; $videouserwallet = $userwallet->wallet+$uploader_amount; $db->where('id', $video->user_id); $update_wallet = $db->update(T_USERS, [ // 'wallet' => $videouserwallet, 'wallet' => number_format($videouserwallet, 2, '.', ''), ]); } $db->where('id', $user_id); $update_wallet = $db->update(T_USERS, [ 'wallet' => $new_wallet, ]); if (($inserted_records == $count_video) && $update_wallet) { $db->commit(); echo json_encode([ 'status' => 200 ]); exit(); } else { $db->rollback(); echo json_encode([ 'status' => 400, 'error' => 'Buy process error' ]); exit(); } } else { echo json_encode([ 'status' => 400, 'error_num' => 1, 'error' => 'Not enough money' ]); exit(); } } else { echo json_encode([ 'status' => 400, 'error' => 'Bad Request, Invalid or missing parameter' ]); exit(); }
Hi, I need field calculation formula. I have following four fields. I want to calculate End Date based on values in Tracking Unit, Total Units and Start Date. Tracking Unit (Daily,Weekly,Monthly,Quarterly) for example Tracking Unit => Monthly Total Units => 12 Start Date => 2011-01-01 End Date => 2011-12-01 another example Tracking Unit => Weekly Total Units => 12 Start Date => 2011-01-01 End Date => ? I want to calculate End Date either in PHP or Javascript. Any idea? Hello all. Trying this again. I would like to implement a simple math formula based on a date, but not sure how to do that exactly. I run a sports league, and want to calculate fees based upon a fixed date. Prior to 'some date' use this calculation, but after this date, add late fees using 2nd calculation. In my code there are two fields: $earlyteam and $lateteam. I need $lateteam to kick in after 'some date'. Help? Code: [Select] //calculate Fees $size = $lSize['size']; switch($size) { case 2: $base = 150; $size = 3; break; case 4: $base = 330; $size = 6; break; case 6: $base = 550; $size = 10; break; default: die ("invalid league size"); }; $earlyTeam = $base; { $e_each = $earlyTeam / $pCount; $lateTeam = $earlyTeam * 1.10; $l_each = $lateTeam / $pCount; } I am trying to write a script for a puzzle based on the user's IP address, but I just can't wrap my head around how to do it. Essentially, when the visitor loads the page two things happen: (1) a PHP application returns an image to serve as a background for the formula, (2) implement the algorithm of generating the formula based on IP, that is displayed on the image.
The puzzle itself would be in the form of ABC.DEF.GHI.JKL where each letter would be associated with the corresponding digit in their IP addy. The user is trying to solve for partial map coordinates. So, let's say the correct answer is N 35 54.374 W 084 01.829 and the user's IP is 075.036.025.058. The formula returned and placed on the image would be N 35 54. (E) (B) (F - H) W 084 01. (L) (H) (B + H) Whatever I use as the final correct answer will not change and be the same for all users; only the puzzle formula would differ for each user as it would be based on their IP at the moment. Any help here would be greatly appreciated. Thanks! Gary This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=348108.0 Hi there, I would like to customize $shippingCost in my shopping cart. I follow a tutorial from: http://www.phpwebcommerce.com/plaincart/index.php This tutorial using flat shipping rate, how to customize shippingCost based on the product weight ? Example: shipping method will based on weight & place within Malaysia: west malaysia, up to 1kg = rm9 east malaysia, up to 1kg = rm12 west malaysia, up to 2kg = rm12 east malaysia, up to 2kg = rm16 west malaysia, up to 5kg = rm18 east malaysia, up to 5kg = rm32 west malaysia, up to 10kg = rm24 east malaysia, up to 10kg = rm48 Do i need to create a new field inside my database for product weight ? is it $weight * $product_quantity ? Does anyone know how to accomplish this customization? . Please help because I am very confuse. Thank you in advanced checkout-functions.php: Code: [Select] <?php require_once 'config.php'; /********************************************************* * CHECKOUT FUNCTIONS *********************************************************/ function saveOrder() { $orderId = 0; $shippingCost = 5; $requiredField = array('hidShippingFirstName', 'hidShippingLastName', 'hidShippingAddress1', 'hidShippingCity', 'hidShippingPostalCode', 'hidPaymentFirstName', 'hidPaymentLastName', 'hidPaymentAddress1', 'hidPaymentCity', 'hidPaymentPostalCode'); if (checkRequiredPost($requiredField)) { extract($_POST); // make sure the first character in the // customer and city name are properly upper cased $hidShippingFirstName = ucwords($hidShippingFirstName); $hidShippingLastName = ucwords($hidShippingLastName); $hidPaymentFirstName = ucwords($hidPaymentFirstName); $hidPaymentLastName = ucwords($hidPaymentLastName); $hidShippingCity = ucwords($hidShippingCity); $hidPaymentCity = ucwords($hidPaymentCity); $cartContent = getCartContent(); $numItem = count($cartContent); // save order & get order id $sql = "INSERT INTO tbl_order(od_date, od_last_update, od_shipping_first_name, od_shipping_last_name, od_shipping_address1, od_shipping_address2, od_shipping_phone, od_shipping_state, od_shipping_city, od_shipping_postal_code, od_shipping_cost, od_payment_first_name, od_payment_last_name, od_payment_address1, od_payment_address2, od_payment_phone, od_payment_state, od_payment_city, od_payment_postal_code) VALUES (NOW(), NOW(), '$hidShippingFirstName', '$hidShippingLastName', '$hidShippingAddress1', '$hidShippingAddress2', '$hidShippingPhone', '$hidShippingState', '$hidShippingCity', '$hidShippingPostalCode', '$shippingCost', '$hidPaymentFirstName', '$hidPaymentLastName', '$hidPaymentAddress1', '$hidPaymentAddress2', '$hidPaymentPhone', '$hidPaymentState', '$hidPaymentCity', '$hidPaymentPostalCode')"; $result = dbQuery($sql); // get the order id $orderId = dbInsertId(); if ($orderId) { // save order items for ($i = 0; $i < $numItem; $i++) { $sql = "INSERT INTO tbl_order_item(od_id, pd_id, od_qty) VALUES ($orderId, {$cartContent[$i]['pd_id']}, {$cartContent[$i]['ct_qty']})"; $result = dbQuery($sql); } // update product stock for ($i = 0; $i < $numItem; $i++) { $sql = "UPDATE tbl_product SET pd_qty = pd_qty - {$cartContent[$i]['ct_qty']} WHERE pd_id = {$cartContent[$i]['pd_id']}"; $result = dbQuery($sql); } // then remove the ordered items from cart for ($i = 0; $i < $numItem; $i++) { $sql = "DELETE FROM tbl_cart WHERE ct_id = {$cartContent[$i]['ct_id']}"; $result = dbQuery($sql); } } } return $orderId; } /* Get order total amount ( total purchase + shipping cost ) */ function getOrderAmount($orderId) { $orderAmount = 0; $sql = "SELECT SUM(pd_price * od_qty) FROM tbl_order_item oi, tbl_product p WHERE oi.pd_id = p.pd_id and oi.od_id = $orderId UNION SELECT od_shipping_cost FROM tbl_order WHERE od_id = $orderId"; $result = dbQuery($sql); if (dbNumRows($result) == 2) { $row = dbFetchRow($result); $totalPurchase = $row[0]; $row = dbFetchRow($result); $shippingCost = $row[0]; $orderAmount = $totalPurchase + $shippingCost; } return $orderAmount; } ?> any help will be greatly appreciated Hi,
Please can someone point me in the right direction to solving this.
The following code set the postage rate on a basket. It selects the lowest postage assigned to a product and set that as the postage rate.
I now need this to work the opposite way round and select the highest postage rate of the added products.
The postage rates are stored in the database as:
0=0.00
1=4.95
2=7.95
3=12.95
So it looks like somewhere there has been something added that tells it to always give preference to the "0" of any products giving the lowest postage but I'm sure on this....
Thanks.
//set default postage value outside loop $postagerate = 15.00; Hi there Does anyone know where can i get php/mysql calculation weight & shipping cost tutorial ? Thank you in advanced! I have been looking at this code most of the morning and do not have a clue what is wrong with the code. I am hoping its not a stupid mistake, can someone please help me out? thank you
<title>Inputing Travel Detials</title> <header> <h1 align="center"> Adding Travel Detials </h1> <body> <p> <center><img src="cyberwarfareimage1.png" alt="Squadron logo" style="width:200px;height:200px" style="middle"></center> <table border="1"> <tr> <td><a href="index.php"> Home Page </a></td> <td><a href="administratorhomepage.html">Administrator Home Page </a></td> <td><a href="viewhomepage.html">View Home Page </a></td> <td><a href="Inputhomepage.html">Input Home Page </a></td> <td><a href="traveldetials.html">Enter More Travel Detials </a></td> </table> </p> <?php include "connection.php"; $Applicant_ID = $_POST["Applicant_ID"]; $Method_Of_Travel = $_POST["Method_Of_Travel"]; $Cost = $_POST["Cost"]; $ETA = $_POST["ETA"]; $Main_Gate_Advised = $_POST["Main_Gate_Advised"]; $query = ("UPDATE `int_board_applicant` SET `Method_Of_Travel`=`$Method_Of_Travel', `Cost`=`$Cost', `ETA`='$ETA', `Main_Gate_Advised`='$Main_Gate_Advised' WHERE `Applicant_ID`='$Applicant_ID'"); $result = mysqli_query($dbhandle, $query) or die(mysqli_error($dbhandle)); if($result){ echo "Success!"; } else{ echo "Error."; } // successfully insert data into database, displays message "Successful". if($query){ echo "Successful"; } else { echo "Data not Submitted"; } //closing the connection mysqli_close($dbhandle) ?> |