How can I get the remainder from two values from MySQL in PHP?
-
Hi, I'm new to php and MySQL. I'm trying to create a chart which displays numerical data from MySQL. I could draw a chart with pChart, but I couldn't get the remainder of two values. Well, this is MySQL data table (first row and second row) ------------- | 1 | 245 | 245 (245-null) | 2 | 412 | 167 (412-245) | 3 | 624 | 212 (624-412) | 4 | 124 | -500 (124-624) ------------- I can display with second column's data (245, 412, 624, 124). And I want to display the third column's data (which is the remainder of two values and not exist in MySQL table; I have to figure in php.) However, I could not find out what formula should I use. Does anyone know the answer? or could show me the sample code?
-
Answer:
You want to use modular arithmetic, which, in MySQL, is the '%' operator. So, for example: mysql> select 412 % 245; +-----------+ | 412 % 245 | +-----------+ | 167 | +-----------+ 1 row in set (0.00 sec)
Joe Emison at Quora Visit the source
Related Q & A:
- How can I get rid of the "Get IE7 now!" button on the Yahoo Toolbar?Best solution by Yahoo! Answers
- How can I get an audio alert when I get a new e-mail?Best solution by Yahoo! Answers
- How can I separate a video into two parts?Best solution by Yahoo! Answers
- How can I get Bahrain police clearance and were can I apply for it in Australia?Best solution by Yahoo! Answers
- How can I get a text alert when I get an email?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.