php en mysqli en table geven onjuiste format weer.

Overzicht Reageren

Sponsored by: Vacatures door Monsterboard

Thomas de vries

thomas de vries

20/07/2017 11:43:33
Quote Anchor link
Goeden dag,

ik probeer een output te genereren op basis van gegevens vanuit de database.
op zich gaat mij dit redelijk af.
Ik loop alleen tegen het volgende aan

ik werk met 2 tabellen.
links komen de users te staan met 2 andere gegevens.
En aan de rechter kant komen x aantal runs met datum te staan.

Voorbeeld
Afbeelding

Als ik nu de rechter kant met gegevens vul dan klopt het niet meer.
Afbeelding

Dit is wat ik gebruik. P.s het ziet er nu niet mooi uit. Opmaak wordt aangewerkt waneer ik dit werkend heb.
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
<?php
                $query
= $db->query('
                    SELECT
                        SUM(gold_sended) AS gold_sended1,
                        gold_swap_id,
                        gold_sended,
                        user_id,
                        week,
                        google_users.oauth_uid,
                        google_users.portal_name,
                        gold_swap_value.id,
                        gold_swap_value.gold_swap_value
                    FROM
                        gold_sended,
                        google_users,
                        gold_swap_value
                    WHERE
                        (gold_swap_id = "'
.$db->real_escape_string($_GET['a']).'")
                    AND
                        (week = "'
.$week.'")
                    AND
                        (gold_swap_id = gold_swap_value.id)
                    AND
                        (gold_sended.user_id = google_users.oauth_uid) GROUP BY google_users.portal_name'
);
                        $i = 0;
                        ?>

<div class="block">
        <div class="block-bot">
          <div class="head">
            <div class="head-cnt">
              <h3>User Swap Values:</h3>
              <div class="cl">&nbsp;</div>
            </div>
          </div>
          <div class="row-articles articles">
            <div class="cl">&nbsp;</div>
            
            <div class="article">
              <div class="cl">&nbsp;</div>
                <!-- Content HERE-->
                <div style="width:650px; overflow: hidden;">
                    <div style="width:620px; background-color:#000; float:left; overflow:auto;">
                    <table width="100%" border="1" style="border-collapse: collapse; ">
                    <tr>
                        <td>
                            <table width="50%" border="1" style="border-collapse: collapse; ">
                            <tr>
                                <td>Name:</td>
                                <td>Remaining:</td>
                                <td>Total:</td>
                            </tr>
                            <?php
                            $i
= 1;
                            while($res = $query->fetch_assoc())
                            {

                                echo '<tr>
                                <td>'
.$res['portal_name'].'</td>
                                <td>'
.number_format($res['gold_swap_value'] - $res['gold_sended1']).'</td>
                                <td>'
.number_format($res['gold_sended1']).'</td>';
                                $i++;
                                $account = $res['oauth_uid'];
                            }

                            ?>

                            </tr>
                            </table>
                        </td>
                        <td>&nbsp;</td>
                        <td>
                            <table width="100%" border="1" style="border-collapse: collapse; ">
                            <tr>
                            <?php
                            for($i = 1; $i < 50; $i++)
                            {

                                echo '<td>Run '.$i.':</td><td>Date</td>';
                            }

                            ?>

                            </tr>
                            <tr>
                            <?php
                            $query1
= $db->query('
                            SELECT
                                gold_sended,
                                gold_swap_id,
                                user_id,
                                week,
                                date,
                                google_users.oauth_uid,
                                google_users.portal_name
                            FROM
                                gold_sended,
                                google_users
                            WHERE
                                (gold_swap_id = "'
.$db->real_escape_string($_GET['a']).'")
                            AND
                                (week = "'
.$week.'")
                            AND
                                (google_users.oauth_uid = "'
.$account.'")');
                            while($res1 = $query1->fetch_assoc())
                            {

                                echo '<td>'.$res1['gold_sended'].'</td><td>'.$res1['date'].'</td>';
                                //echo '<td>Test</td><td>Datum</td>';
                            }
                            ?>

                    
                            </tr>
                            </table>
                        </td>
                    </tr>
                    </table>
                    </div>
                </div>
            </div>

            <div class="article last-article">
              <div class="cl">&nbsp;</div>
              
              <div class="cl">&nbsp;</div>
            </div>
            <div class="cl">&nbsp;</div>
          </div>
        </div>
      </div>


Het moet dus als volgt gebeuren.
Linker tabel zoals hierboven staat. Komen dus username remaining en totaal verstuurd goud te staan.
Rechter tabel moet dus de gegevens bevatten van elke user in een andere rij.
Nu stopt die alle runs van alle users in 1 rij.
laatste voorbeeld geeft aan dat user imagination 4 runs heeft met de waardes. Echter die laatste waarde is van de user test.

Ik kom er helaas even niet meer uit.
Elke tip is welkom.

Met vriendelijke groet,

Thomas de Vries.
Gewijzigd op 20/07/2017 11:44:12 door Thomas de vries
 
PHP hulp

PHP hulp

21/11/2024 22:53:08
 
- Ariën  -
Beheerder

- Ariën -

20/07/2017 11:49:50
Quote Anchor link
Tabellen in tabellen is een behoorlijke crime waarbij je terug lijkt te denken aan vroeger. Waarom niet met divjes, floats en clear's de boel indelen?
 
Thomas de vries

thomas de vries

20/07/2017 12:56:23
Quote Anchor link
Hoi Ariën ja dat is idd iets van vroeger uit.

Ja ik kan het wel idd met divjes etc doen. wordt het wel wat overzichtelijker.
Ik zal het eerst overzichtelijker maken.
 
Willem vp

Willem vp

20/07/2017 15:26:43
Quote Anchor link
Moet die </tr> van regel 64 niet binnen de while-loop vallen? Je maakt nu een heleboel <tr>'s aan, maar sluit er slechts 1 af...
 
Thomas de vries

thomas de vries

20/07/2017 15:44:12
Quote Anchor link
dit is hoe ik het nu heb.
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
<?php
                $query
= $db->query('
                    SELECT
                        SUM(gold_sended) AS gold_sended1,
                        gold_swap_id,
                        gold_sended,
                        user_id,
                        week,
                        google_users.oauth_uid,
                        google_users.portal_name,
                        gold_swap_value.id,
                        gold_swap_value.gold_swap_value
                    FROM
                        gold_sended,
                        google_users,
                        gold_swap_value
                    WHERE
                        (gold_swap_id = "'
.$db->real_escape_string($_GET['a']).'")
                    AND
                        (week = "'
.$week.'")
                    AND
                        (gold_swap_id = gold_swap_value.id)
                    AND
                        (gold_sended.user_id = google_users.oauth_uid) GROUP BY google_users.portal_name'
);
                        $i = 0;
                        ?>

<div class="block">
        <div class="block-bot">
          <div class="head">
            <div class="head-cnt">
              <h3>User Swap Values:</h3>
              <div class="cl">&nbsp;</div>
            </div>
          </div>
          <div class="row-articles articles">
            <div class="cl">&nbsp;</div>
            
            <div class="article">
              <div class="cl">&nbsp;</div>
                <!-- Content HERE-->
                <div style="width:640px; overflow: hidden; background-color:;">
                    <div class="users_data" style="width:300px; background-color:#000; float:left; ">
                        <?php
                        $query
= $db->query('SELECT
                            user_id,
                            gold_swap_id,
                            gold_swap_value.id,
                            gold_swap_value.gold_swap_value,
                            google_users.oauth_uid,
                            google_users.portal_name
                        FROM
                            register_gold_swap,
                            gold_swap_value,
                            google_users
                        WHERE
                            gold_swap_id = "'
.$db->real_escape_string($_GET['a']).'"
                        AND
                            (gold_swap_value.id = gold_swap_id)
                        AND
                            (user_id = google_users.oauth_uid)
                            ORDER BY google_users.portal_name ASC
                        '
);
                        $count_rows = $query->num_rows;
                        ?>

                        <table width="100%" border="1">
                        <tr>
                            <td>Name:</td>
                            <td>Remaining:</td>
                            <td>Total:</td>
                        </tr>
                        <?php
                        while($res = $query->fetch_assoc())
                        {

                            $goldQuery = $db->query('
                            SELECT
                                SUM(gold_sended) AS total_gold,
                                user_id,
                                gold_swap_id,
                                gold_swap_value.id,
                                gold_swap_value.gold_swap_value
                            FROM
                                gold_sended,
                                gold_swap_value
                            WHERE
                                user_id = "'
.$res['oauth_uid'].'"
                            AND
                                (gold_swap_id = gold_swap_value.id)
                            AND
                                (gold_swap_id = "'
.$res['gold_swap_id'].'")');
                            $gold = $goldQuery->fetch_assoc();
                            $calcRemaining = $res['gold_swap_value'] - $gold['total_gold'];
                            if($calcRemaining == $res['gold_swap_value']) {
                                $remaining = '<td bgcolor="red"><font color="black">'.number_format($res['gold_swap_value']).'<font></td>';
                            }
else {
                                $remaining = '<td bgcolor="orange"><font color="black">'.number_format($calcRemaining).'</font></td>';
                            }

                            echo '
                            <tr>
                                <td>'
.$res['portal_name'].'</td>
                                '
.$remaining.'
                                <td>'
.number_format($gold['total_gold']).'</td>';
                        }

                        ?>

                        </tr>
                        </table>
                    </div>
                    
                    <div class="users_content" style="width:320px; float:right; background-color:#3e3e3e; overflow:auto;">
                        <table width="100%" border="1" style="table-layout:fixed;">
                        <tr>
                        <?php
                        for($i = 1; $i < 50; $i++)
                        {

                            echo '
                                <td width="100px">Run '
.$i.':</td>
                                <td width="100px">Date</td>'
;
                                
                        }

                        ?>

                        </tr>
                        <tr>
                        <?php
                        $query_a
= $db->query('SELECT
                            user_id,
                            gold_swap_id,
                            gold_sended,
                            date,
                            gold_swap_value.id,
                            gold_swap_value.gold_swap_value,
                            google_users.oauth_uid,
                            google_users.portal_name
                        FROM
                            gold_sended,
                            gold_swap_value,
                            google_users
                        WHERE
                            gold_swap_id = "'
.$db->real_escape_string($_GET['a']).'"
                        AND
                            (gold_swap_value.id = gold_swap_id)
                        AND
                            (user_id = google_users.oauth_uid)
                            ORDER BY google_users.portal_name ASC
                        '
);
                            while($res_a = $query_a->fetch_assoc())
                            {

                            echo '
                                <td>'
.$res_a['gold_sended'].'</td>
                                <td>'
.$res_a['date'].'</td>';
                            }

                            ?>

                        </tr>
                        </table>
                    </div>
                    <div style="clear:both;"></div>
                </div>
            </div>

            <div class="article last-article">
              <div class="cl">&nbsp;</div>
              
              <div class="cl">&nbsp;</div>
            </div>
            <div class="cl">&nbsp;</div>
          </div>
        </div>
      </div>


Echter geeft die nog steeds dit
Afbeelding
 
- Ariën  -
Beheerder

- Ariën -

20/07/2017 15:49:37
Quote Anchor link
Kan je de output even in een JSfiddle zetten? Dan is het wat makkelijker te debuggen.
 
Willem vp

Willem vp

20/07/2017 15:51:51
Quote Anchor link
In je rechtertabel maak je maar 1 <tr> met resultaten aan. Niet verwonderlijk dat alles dan op dezelfde regel komt. ;-)

Je zou binnen de while-loop van regel 144 kunnen controleren of de portal_name is gewijzigd ten opzichte van de vorige waarde. Zo ja, dan begin je een nieuwe <tr>.
Gewijzigd op 20/07/2017 15:52:52 door Willem vp
 
Thomas de vries

thomas de vries

21/07/2017 08:44:55
Quote Anchor link
Hoi Willem,

Ja ik had al een aantal dingen geprobeerd maar lijkt erop dat of ik denk te moeilijk of er is iets anders.

ik heb dus 2 tables

gold_sended
user_id | gold_swap_id | gold_sended | date

google_users
oauth_uid | portal_name

gold_sended heeft data als
user_id = 1
gold_swap_id = 1
gold_sended = 1000000
date = datum.

user_id = 1
gold_swap_id = 1
gold_sended = 1500000
date = datum

user_id = 2
gold_swap_id = 2
gold_sended = 10000
date = datum

google_users
oauth_uid = 1
portal_name = test

oauth_uid = 2
portal_name = test2


in de linker table komen dus de gegevens te staan van de users met het totaal verzonden en wat ze nog dienen te verzenden.

Dit gebeurt doormiddel van group by portal_name anders komen die namen er 2 keer te staan.

in de rechter tabel moeten dus de gegevens komen van de user die ook in de linker tabel staan.

dus even een ruwe schets.
Afbeelding

Zoals jullie zien kan het dus zijn dat user 1 meer gold heeft verstuurd dan user 2.
etc.
 
Thomas van den Heuvel

Thomas van den Heuvel

21/07/2017 10:26:53
Quote Anchor link
Ik denk dat je hier met alle geweld twee verschillende typen informatie wilt combineren: een soort van samenvatting en een bijbehorende gedetailleerde beschrijving.

Als je deze nu eens opsplitst (op wat voor manier dan ook)? Je zou in eerste instantie alleen de linker tabel kunnen laten zien, en dan op een details-link kunnen klikken waarna je of naar een aparte pagina gaat, of dat er een soort van verborgen div uitklapt met een lijstje van "runs" hierin, desnoods on-the-fly opgehaald met een AJAX-call (of wat dan ook, gebruik je verbeelding :p).

Ook is het meestal zo dat een layout verticaal makkelijker uitbreidbaar is dan horizontaal dus ik zou die runs hoe dan ook onder elkaar zetten, en niet naast elkaar.
 
Thomas de vries

thomas de vries

21/07/2017 11:04:50
Quote Anchor link
Hoi Thomas,
Ja dit dient idd zo te gaan ivm we nu werken met google sheets. De owner wil dit graag zo zien.
Ik kan natuurlijk 1 tabel maken alleen het eerste gedeelte moet dan fixed zijn. en het 2de gedeelte scrollbaar.
Echter werkt dit niet.

Dus dien ik het zo te doen.

Nu heb ik bijna de oplossing gevonden.
code zoals die nu is
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<div style="width:640px; overflow: hidden; background-color:;">
                    <div class="users_data" style="width:300px; background-color:#000; float:left; ">
                        <?php
                        $query
= $db->query('SELECT *,
                            SUM(gold_sended) as total_gold
                        FROM
                            gold_sended
                        INNER JOIN
                            google_users ON (gold_sended.user_id = google_users.oauth_uid)
                        INNER JOIN
                            gold_swap_value ON (gold_sended.gold_swap_id = gold_swap_value.id)
                        WHERE
                            gold_sended.week = "29"
                        AND
                            (gold_sended.gold_swap_id = "'
.$db->real_escape_string($_GET['a']).'")
                        GROUP BY
                            user_id
                        ORDER BY
                            google_users.portal_name ASC'
);
                        ?>

                        <table width="100%" border="1">
                        <tr>
                            <td>Name:</td>
                            <td>Remaining:</td>
                            <td>Total:</td>
                        </tr>
                        <?php
                        while($res = $query->fetch_assoc())
                        {

                            $calcRemaining = $res['gold_swap_value'] - $res['total_gold'];
                            if($calcRemaining == $res['gold_swap_value']) {
                                $remaining = '<td bgcolor="red"><font color="black">'.number_format($res['gold_swap_value']).'<font></td>';
                            }
else {
                                $remaining = '<td bgcolor="orange"><font color="black">'.number_format($calcRemaining).'</font></td>';
                            }

                            echo '
                            <tr>
                                <td>'
.$res['portal_name'].'</td>
                                '
.$remaining.'
                                <td>'
.$res['total_gold'].'</td>';
                                $account[] = $res['portal_name'];
                        }

                        ?>

                        </tr>
                        </table>
                    </div>
                    <div class="users_content" style="width:320px; float:right; background-color:#3e3e3e; overflow:auto;">
                    <table width="100%" border="1" style="table-layout:fixed;">
                        <tr>
                        <?php
                        for($i = 1; $i < 50; $i++)
                        {

                            echo '
                                <td width="100px">Run '
.$i.':</td>
                                <td width="100px">Date</td>'
;
                                
                        }

                        ?>

                        </tr>
                        <tr>
                        <?php
                        $query1
= $db->query('
                        SELECT * FROM gold_sended, google_users WHERE gold_sended.user_id = google_users.oauth_uid AND (week = "29") AND (gold_sended.gold_swap_id = "1") ORDER BY google_users.portal_name ASC'
);
                        $i = 0;
                        while($res1 = $query1->fetch_assoc())
                        {

                            $countQuery = $db->query('SELECT *, COUNT(gold_sended) as total_gold FROM gold_sended WHERE gold_sended.user_id = "'.$res1['oauth_uid'].'" AND (gold_swap_id = "1") AND (week = "29")');
                            $count = $countQuery->fetch_assoc();
                            if($i >= $count['total_gold']) { echo '</tr><tr>'; $i = 0;}
                            echo '<td>'.$res1['gold_sended'].'</td>
                            <td>'
.$count['total_gold'].'</td>';
                            $i++;
                        }

                        ?>

                        </tr>
                    </table>
                    </div>
                    <!--OTHER_DIV-->
                    <div style="clear:both;"></div>
                </div>


Output is nu zo
Afbeelding

Heb het nu ook op JSFiddle neergezet.
https://jsfiddle.net/1zzsxruw/

Het gaat nu om dit stukje
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
$query1 = $db->query('
                        SELECT * FROM gold_sended, google_users WHERE gold_sended.user_id = google_users.oauth_uid AND (week = "29") AND (gold_sended.gold_swap_id = "1") ORDER BY google_users.portal_name ASC');
                        $i = 0;
                        while($res1 = $query1->fetch_assoc())
                        {
                            $countQuery = $db->query('SELECT *, COUNT(gold_sended) as total_gold FROM gold_sended WHERE gold_sended.user_id = "'.$res1['oauth_uid'].'" AND (gold_swap_id = "1") AND (week = "29")');
                            $count = $countQuery->fetch_assoc();
                            if($i >= $count['total_gold']) { echo '</tr><tr>'; $i = 0;}
                            echo '<td>'.$res1['gold_sended'].'</td>
                            <td>'.$count['total_gold'].'</td>';
                            $i++;
                        }
                        ?>



Output:
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
<tr>
                        <td>150000000</td>
                            <td>1</td><td>49665854</td>
                            <td>4</td><td>650111382</td>
                            <td>4</td><td>650111382</td>
                            <td>4</td></tr><tr><td>650111382</td>
                            <td>4</td></tr><tr><td>1000000000</td>
                            <td>1</td>                        </tr>


Na die eerste 2 TD's moet een TR komen.
Die andere doet die wel goed.
 
Thomas van den Heuvel

Thomas van den Heuvel

21/07/2017 13:00:28
Quote Anchor link
En als je nu eerst eens alle info ophaalt en in een array opslaat onder eenzelfde oauth_uid, en dit array daarna uitdraait? Lijkt mij een stuk makkelijker.

Je zult trouwens het maximale aantal runs van iemand ergens moeten bijhouden, en de andere rijen opvullen met een colspan ter grootte van het verschil tussen max en runs van de huidige rij. Dit ten einde syntactisch kloppende HTML te schrijven. Simpelweg omdat de/een browser het correct rendert wil niet zeggen dat het klopt.

Ben eigenlijk nog steeds voor een andere opbouw, klinkt niet alsof de owner veel kaas heeft gegeten van interface design.
 
Thomas de vries

thomas de vries

22/07/2017 11:31:08
Quote Anchor link
Zo even een update.
Code heb ik nu werkend gekregen zoals het bedoelt is. Op 1 ding nu na haha.

code zoals die nu is
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<?php
$Portal_Name
= array();
$query = $db->query('SELECT * FROM register_gold_swap WHERE register_gold_swap.gold_swap_id = "'.$db->real_escape_string($_GET['a']).'" AND (status = "1")');
$sum = 0;
while($res = $query->fetch_assoc())
{

    $query1 = $db->query('SELECT * FROM gold_sended WHERE user_id = "'.$res['user_id'].'" AND gold_swap_id = "'.$res['gold_swap_id'].'"');
    while($res1 = $query1->fetch_assoc())
    {

        //echo $res1['gold_sended'].'<br />';
        $total[] = array($res1['gold_sended'], $res1['user_id']);
    }

    $query3 = $db->query('SELECT * FROM google_users WHERE oauth_uid = "'.$res['user_id'].'" ORDER BY portal_name ASC');
    $res3 = $query3->fetch_assoc();
    $PortalName[] = array($res3['portal_name'],$res3['oauth_uid']);
}

?>

<div class="block">
        <div class="block-bot">
          <div class="head">
            <div class="head-cnt">
              <h3>User Swap Values:</h3>
              <div class="cl">&nbsp;</div>
            </div>
          </div>
          <div class="row-articles articles">
            <div class="cl">&nbsp;</div>
            
            <div class="article">
              <div class="cl">&nbsp;</div>
                <!-- Content HERE-->
                <div style="width:640px; overflow: hidden; background-color:;">
                    <div class="users_data" style="width:300px; background-color:; float:left; ">
                    <table width="100%" border="1" style="border-collapse:collapse;">
                        <tr>
                            <td>Name:</td>
                            <td>Remaining:</td>
                            <td>Total:</td>
                        <?php
                        foreach($PortalName AS $data)
                        {

                            echo '<tr><td>'.$data[0].'</td>';
                            
                            $countQuery = $db->query('SELECT *, SUM(gold_sended) as total_gold FROM gold_sended WHERE gold_sended.user_id = "'.$data[1].'" AND (gold_swap_id = "'.$db->real_escape_string($_GET['a']).'") AND (week = "29") ORDER BY date DESC');
                            $count = $countQuery->fetch_assoc();
                            $queryA = $db->query('SELECT * FROM gold_swap_value WHERE id = "'.$db->real_escape_string($_GET['a']).'"');
                            $resa = $queryA->fetch_assoc();
                            
                            $calcRemaining = $resa['gold_swap_value'] - $count['total_gold'];
                            if($calcRemaining == $resa['gold_swap_value']) {
                                $remaining = '<td bgcolor="red"><font color="black">'.number_format($resa['gold_swap_value']).'<font></td>';
                            }
else if( $calcRemaining <= 0 ) {
                                $remaining = '<td bgcolor="orange"><font color="black">0</font></td>';
                            }
else {
                                $remaining = '<td bgcolor="orange"><font color="black">'.number_format($calcRemaining).'</font></td>';
                            }

                            
                            echo $remaining.'<td>'.number_format($count['total_gold']).'</td>';
                        }

                        ?>

                        </tr>
                    </table>
                    </div>
                    <div class="users_content" style="width:320px; float:right; background-color:; overflow:auto;">
                    <table width="100%" border="1" style="table-layout:fixed; border-collapse:collapse;">
                        <tr>
                        <?php
                        for($i = 1; $i < 50; $i++)
                        {

                            echo '
                                <td width="100px">Run '
.$i.':</td>
                                <td width="150px">Date</td>'
;
                                
                        }

                        ?>

                        </tr>
                        <tr>
                        <?php
                        $j
=0;
                        foreach($total as $data)
                        {

                            $countQuery = $db->query('SELECT *, COUNT(gold_sended) as total_runs FROM gold_sended WHERE gold_sended.user_id = "'.$data[1].'" AND (gold_swap_id = "'.$db->real_escape_string($_GET['a']).'") AND (week = "29") ORDER BY date DESC');
                            $count = $countQuery->fetch_assoc();
                            if($j % $count['total_runs'] == 0 && $j > 0) {
                                echo '</tr><tr>';
                            }

                            echo '<td>'.number_format($data[0]).'</td><td bgcolor="Yellow"><font color="#000">'.$count['date'].'</font></td>';
                            $j++;
                        }

                        ?>

                        </tr>
                    </table>
                    </div>
                    <!--OTHER_DIV-->
                    <div style="clear:both;"></div>
                </div>
            </div>

            <div class="article last-article">
              <div class="cl">&nbsp;</div>
              
              <div class="cl">&nbsp;</div>
            </div>
            <div class="cl">&nbsp;</div>
          </div>
        </div>
      </div>


Ouput:
Afbeelding

Zoals jullie zien is er 1 gebruiker die nog niks heeft verzonden. Nu dien ik dus te controleren of die user_id wel voorkomt in de tabel gold_sended. Zo niet dan lege rij.
 



Overzicht Reageren

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.