How can display multiple values to single column?

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

Was this solution helpful to you?

Just Added Q & A:

Find solution

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.