foreach loop with if statements [closed] - php

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 days ago.
Improve this question
<?php
$income = array(19500, 22000, 85205, 110000, 26568, 12000, 37500, 50900, 28000, 32430);
$percentage = 0.09;
foreach($income as $integers)
{
echo ("$integers <br/>");
}
if ($integers < 26568);
{
echo "$integers = Pay back £0 per year";
}
?>
outcome below
19500
22000
85205
110000
26568
12000
37500
50900
28000
32430
32430 = Pay back £0 per year
If it is lower than 26568 then next to the number I want it to say "Pay back £0 per year" but if it's more than 26568 I need to calculate 9 percentage and add how much is paid back next to the number. Is this possible?
I tried the above and keep getting the same output, I need to be able to calculate the 9 percent and add this next to the number.

Related

Get all results of 1 year ago and older datetime field [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 12 months ago.
Improve this question
I want to check if an membership of an user is created 1 year ago or longer.
I have this now:
SELECT * FROM users WHERE date >= NOW() - INTERVAL 1 YEAR
But i get results of 17-03-2021 in the list, when that is not an year ago.
I want to get all results from the Users when created account one year ago
or longer than.
How i can do that? I googled but i cant find an solution.
Thanks in advance.
SELECT * FROM users WHERE date < NOW() - INTERVAL 1 YEAR
Where date smaller then one year ago, you had greater then.

How to query data expiration time in mysql php [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 4 years ago.
Improve this question
In my Database I have products that i saved with the expiration timestamp in the format eg. 2018-22-08. Please how do I select all products that will expire in less than 4 days.
I have tried
SELECT * FROM table WHERE expiration_timestamp = DATE_ADD(CURDATE(), INTERVAL 4 DAY)
You should use less than operator
SELECT * FROM table WHERE expiration_timestamp < DATE_ADD(CURDATE(), INTERVAL 4 DAY)

This code is not decreasing the value by 1 [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 5 years ago.
Improve this question
I want to update next table named 'book' but this UPDATE code is not working
"UPDATE books SET Quantity=Quantity-1 Where Book_ID='$Book_ID'";
this code should update the books table by decreasing the value of Quantity by 1
You need to decrease from column value, not PHP variable. Remove the dollar sign and quotes, of you have there integers.
UPDATE books SET Quantity = Quantity - 1 Where Book_ID = '$Book_ID'
Don't forget that you are vulnerable to SQL injection in WHERE clause.

PHP Calculation from database not calculating correctly. [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 years ago.
Improve this question
I am trying to run a sum from numbers taken from a database. However i can't seem to get it to work.
Does anyone have any ideas as to why i keep getting 0 instead of a percentage? if so could you guide me in the right direction.
PHP:
//SQL Original Goal
$goal = "SELECT * FROM login WHERE username = '$login'";
$goalquery = mysql_query($goal);
$goalarray = mysql_fetch_array($goalquery);
$endgoal = $goalarray['goal'];
//Latest Weight
$latestweightarray = mysql_fetch_array($latestweightq);
$currentweight = $latestweightarray['weight'];
//First Weight Recorded
$firstweightarray = mysql_fetch_array($firstweightq);
$firstweight = $firstweightarray['weight'];
$percent = "100";
$progress = (($firstweight - $currentweight) / ($firstweight - $endgoal)) * $percent;
Print Result:
<?php
echo $progress
?>
This just gives: 0
Rookie Error, i had updated the database twice in one day which conflicted the results somehow, changed one of the dates in the database and this solved the problem

Diffrence between a dot and comma in cost value in php [closed]

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 9 years ago.
Improve this question
My client(from denmark) give the value to use in cost value in php.
He said " Use this , The Cost is 50.000 Dkr half product , 200.000 Dkr. for full product. "
i am confused in comma and dot ? what is correct value ? its 50.000 or 50,000.
This isn't a coding question
Commas are used in the English convention to separate thousands (50,000 = fifty thousand. 50.000 = fifty point zero zero zero)
In Continental Europe commas are used as the decimal separator (50,5 = fifty and a half)
Please do a bit of research before your next question. This one is easily answered here

Categories