Click here to Skip to main content
15,881,248 members
Home / Discussions / Linux, Apache, MySQL, PHP
   

Linux, Apache, MySQL, PHP

 
QuestionGUI for Linux Server Pin
Deepak Vasudevan25-Jan-22 3:29
Deepak Vasudevan25-Jan-22 3:29 
QuestionError in page rendering in php Pin
Rahul Gupta Jan202217-Jan-22 1:16
Rahul Gupta Jan202217-Jan-22 1:16 
AnswerRe: Error in page rendering in php Pin
Richard Deeming17-Jan-22 1:53
mveRichard Deeming17-Jan-22 1:53 
Questionhow to add date while importing data in csv from mysql query Pin
him_mca16-Jan-22 20:00
him_mca16-Jan-22 20:00 
Questioni want make check user offline with mysql Pin
Ping tester1-Jul-21 10:56
Ping tester1-Jul-21 10:56 
QuestionHow to print for each primary key all the foreign keys column related to it? Pin
EliotSimpleMan5-May-21 14:40
EliotSimpleMan5-May-21 14:40 
AnswerRe: How to print for each primary key all the foreign keys column related to it? Pin
SeanChupas13-May-21 1:50
SeanChupas13-May-21 1:50 
QuestionHow do I calculate the column in PHP union all function Pin
Developer Account18-Apr-21 23:12
Developer Account18-Apr-21 23:12 
<pre>I have an issue while calculating the column-like bank statement. actually, I am trying to calculate Opening Balance/today In /today Out / Closing Bal in MySQL PHP. I have two tables. material_infor `IN +` entry and material_approvefor `OUT -`. I am considering my opening balance was `123`.

I am new in PHP and I am here using Union All function. Please help me to create the function for getting Opening / In today / out today/closing calculation in my code.



`table- material_in`

| id   | components_key | insert_date | credit      |
|------|----------------|-------------|-------------|
| 1    | 12345          | 2021-04-16  | 100         |
| 2    | 12345          | 2021-04-16  | 50          |



`table- material_approve`

| id   | components_key | insert_date | debit       |
|------|----------------|-------------|-------------|
| 1    | 12345          | 2021-04-16  | 30          |
| 2    | 12345          | 2021-04-16  | 2           |



<pre>I am trying the code - 

    SELECT
        `u`.`component_key`,
        `u`.`insert_date`,
        `u`.`transaction_qty`
    FROM
        (
        SELECT
            `components_key` AS `component_key`,
            `insert_date`,
            `credit` AS `transaction_qty`
        FROM
            `material_in`
        UNION ALL
        SELECT
            `components_key`,
            `insert_date`,
            `debit` AS `transaction_qty`
        FROM
            `material_approve`
        ) u
    WHERE
        `u`.`component_key` = '12345'
    ORDER BY
        `u`.`insert_date`
    DESC


the output comes - 

| components_key | insert_date | transaction_qty|
|-------------|-------------|------------|
| 12345      | 2021-04-16  | 100         |
| 12345      | 2021-04-16  | 50          |
| 12345      | 2021-04-16  | 30          |
| 12345      | 2021-04-16  | 2           |

`output will be-`

| components_key | insert_date | openbal| today_in | today_out | closebal
|-----------|-------------|-------------|----------|-----------|---------|
|12345      | 2021-04-16  | 123         | 100      | 30        | 193     | 
|12345      | 2021-04-16  | 193         | 243      | 2         | 241     |

//openbal + today_in - today_out  = closebal

AnswerRe: How do I calculate the column in PHP union all function Pin
SeanChupas13-May-21 1:51
SeanChupas13-May-21 1:51 
QuestionPHP :: VSCode always opens a new blank window (untitled-1) Pin
Gustavo Laufer AU4-Apr-21 22:00
Gustavo Laufer AU4-Apr-21 22:00 
AnswerRe: PHP :: VSCode always opens a new blank window (untitled-1) Pin
SeanChupas5-Apr-21 3:15
SeanChupas5-Apr-21 3:15 
Questioni have this errors in my project please i need help Pin
frank saki24-Mar-21 11:55
frank saki24-Mar-21 11:55 
AnswerRe: i have this errors in my project please i need help Pin
Richard Deeming24-Mar-21 22:12
mveRichard Deeming24-Mar-21 22:12 
QuestionHow can I echo the numbers using list() function in foreach loop? Pin
Best Tutor24-Feb-21 9:33
Best Tutor24-Feb-21 9:33 
QuestionRe: How can I echo the numbers using list() function in foreach loop? Pin
Richard MacCutchan24-Feb-21 21:56
mveRichard MacCutchan24-Feb-21 21:56 
QuestionHow to import csv using php code Pin
Mohammed Hudair16-Feb-21 6:24
Mohammed Hudair16-Feb-21 6:24 
QuestionHow to code login page in html css php Pin
Member 150661826-Feb-21 1:01
Member 150661826-Feb-21 1:01 
AnswerRe: How to code login page in html css php Pin
Richard MacCutchan6-Feb-21 1:27
mveRichard MacCutchan6-Feb-21 1:27 
QuestionPosting dropdown value to database Pin
Member 1505550825-Jan-21 2:27
Member 1505550825-Jan-21 2:27 
AnswerRe: Posting dropdown value to database Pin
Richard Deeming25-Jan-21 4:04
mveRichard Deeming25-Jan-21 4:04 
GeneralRe: Posting dropdown value to database Pin
Member 1505550825-Jan-21 6:31
Member 1505550825-Jan-21 6:31 
GeneralRe: Posting dropdown value to database Pin
Richard Deeming25-Jan-21 21:28
mveRichard Deeming25-Jan-21 21:28 
GeneralRe: Posting dropdown value to database Pin
Member 1505550825-Jan-21 21:57
Member 1505550825-Jan-21 21:57 
GeneralRe: Posting dropdown value to database Pin
Richard Deeming25-Jan-21 22:36
mveRichard Deeming25-Jan-21 22:36 
GeneralRe: Posting dropdown value to database Pin
Member 1505550825-Jan-21 22:58
Member 1505550825-Jan-21 22:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.