Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I am creating a fee calculator and fee is calculated on based of capital. So I want a formula in php.
if capital is <=1000000 then fee is 1000
if capital is 1100000 - 2000000 fee is 2000
if capital is 2100000 - 3000000 fee is 3000
if capital is 3100000 - 4000000 fee is 4000
if capital is 4100000 - 5000000 fee is 5000
and so on
so what i want is i want a formula that will give me a fee of 1000 per 10 Lakh
Assuming your variable is called $capital, then this should work:
print ((int)(1000*ceil($capital/1000000)));
It divides by 1000000, rounds up, then multiplies by 1000.
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I have a table that holds prices, the idea behind it is to have users suggest prices they think are reasonable for a good,example; range
You can divide the price by the range size, and then use FLOOR() to get the beginning of the range:
SELECT 1500*FLOOR(price/1500) AS price_base, COUNT(*) AS count
FROM yourTable
GROUP BY price_base
ORDER BY count DESC
For example, price_base = 3000 contains all prices from 3000 to 4499, while price_base = 4500 contains all prices from 4500 to 5999.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I have a table named 'prices' and every range has its price.
course_id start end price
-----------------------------
1 1 5 20
1 5 10 18
1 10 100 15
-------------------------
I have for example $course_id = 1 and $weeks_num = 8.
How can I get the price of that course?
In the given example I should have 18 because 8 exists between 5 and 10.
You can use BETWEEN clause. http://dev.mysql.com/doc/refman/5.7/en/comparison-operators.html#operator_between
...
WHERE 8 BETWEEN start AND end
...
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I have a property website.
At the moment, on the listing, and in search results, it says Number of bedrooms: [pulls the number from the database]. It uses an array variable, $a1[rooms].
Instead, I want to display a small icon of a bed for the number of bedrooms. So if three bedrooms then it should say, Number of bedrooms: [bed img] [bed img] [bed img]. [bed img] of course being a small icon/image of a bed.
So whether there are 1 bedrooms or 5 bedrooms, this is the number of times I want the icon displayed. The number of bedrooms is stored here: $a1[rooms].
Fairly simple really.
Thanks in advance.
Something like this will do the trick:
for ($bed_counter = 1; $bed_counter <= $a1['rooms']; $bed_counter++) {
print '<img src="bed.jpg">';
}
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I have a voting table called product_reviews, with a field that is ENUM from 1 to 5 called rating.
I want to get average rating from all rows with product_id 1665. I am using a star rating system so the average cannot be with decimals. Must be a number from 1 to 5.
Thank you very much.
SELECT round(avg(rating)) as average_review,
count(rating) as number_of_reviews
FROM product_reviews
WHERE product_id = 1665
You need to use round here since avg will return a value between 1.0 and 5.0, and if you use floor or ceil you're effectively eliminating 1 or 5 from the possible results unless all reviews on the product have that score.
Also, you'll alienate your users if they can openly see a product got 50 reviews with 1 star, and 1 review with 2 stars, and you're showing an average score of 2 stars next to that. It'll make your site seem unreliable which is usually not a good thing for a site that contains reviews. For this reason most star rating systems are also capable of showing partial stars to make it more precise.
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
I'm trying to work out a simple calculation for the following:
a phone model has the maximum sale price of £85.00 and this is if only 1 unit is purchased and a minimum sales price of £50.00 - this is if 150 units and over are purchased in one.
How can I work out a way of the price if between 2 and 149 units are purchased??
Thanks,
B.
Formula:
Y = 50 + ((85 - 50) / (150 - 1)) * (X - 1)
Result:
X = 1 --> Y = 85
X = 33 --> Y = 57.52
X = 150 --> Y = 50
You probably don't have a linear model in such situations. I don't know the right English term, but you would have more like a piecewise or stepwise function here.
But nevertheless, you can get a linear function through interpolation.