PHP - Unir ambas querys en una única table

 
Vista:

Unir ambas querys en una única table

Publicado por Kevin (55 intervenciones) el 07/02/2016 18:49:31
Buenas. Actualmente tengo una especie de sección en mi sitio donde muestro los movimientos de una cuenta (de dinero) y poseo dos tables separadas y sus dos respectivas querys. Me gustaría saber si es posible unificar ambas y aplicar un ORDER BY por ID DESC para mostrar todo junto. Ahora están separadas entre: Depósitos que te han realizado (dinero entrante) / Depósitos que has realizado (dinero saliente).

yDWb6o7

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
<div class="panel-body">
                        <center><img src="/imagenes/iconos/suba.png" /> <b><span style="color:green;font-size:11px">Depósitos que te han realizado</span></b><br><br>
                            <div class="table-responsive" style="width:525px;list-style:none;">
                                <table class="table table-striped table-bordered table-hover">
                                    <thead>
                                        <tr>
                                            <th><center><img src="/imagenes/textos/fecha.png" /></center><p></p></th>
                                            <th><center><img src="/imagenes/textos/desde.png" /></center><p></p></th>
                                            <th><center><img src="/imagenes/textos/hacia.png" /></center><p></p></th>
                                            <th><center><img src="/imagenes/textos/cantidad.png" /></center><p></p></th>
                                        </tr>
                                    </thead>
                                    <tbody>
<?php
  $count_rows = 0;
  $sql_select = mysql_query("SELECT * FROM log_transacciones WHERE Destino LIKE '%".$_SESSION['USER:NAME']."%' ORDER BY ID DESC ");
  while($trans = mysql_fetch_array($sql_select))
  {
    $count_rows++;
?>
                                    <tr>
                                            <td><center><p style="font-size:13px"><?php echo $trans['Fecha']; ?></center></td>
                                            <td><center><p style="font-size:13px"><?php echo $trans['Usuario']; ?></center></td>
                                            <td><center><p style="font-size:13px">(<i>CTA <?php echo $player['ID']?>165-<?php echo $player['Numero']?>6<?php echo $player['ID']?>84</i>)</center></td>
                                            <td><center><p style="color:green;font-size:13px">$<?php echo number_format($trans['Cantidad'],0,",","."); ?></center></td>
                                            </td>
                                        </tr>
<?php
  }
?>
                                    </tbody>
                                </table>
                            </div>
                            <center><img style="height:37px;" src="/imagenes/hr/6.png" /></center>
                        <center><img src="/imagenes/iconos/baja.png" /> <b><span style="color:red;font-size:11px">Depósitos que has realizado</span></b><br><br>
                            <div class="table-responsive" style="width:525px;list-style:none;">
                                <table class="table table-striped table-bordered table-hover">
                                    <thead>
                                        <tr>
                                            <th><center><img src="/imagenes/textos/fecha.png" /></center><p></p></th>
                                            <th><center><img src="/imagenes/textos/desde.png" /></center><p></p></th>
                                            <th><center><img src="/imagenes/textos/hacia.png" /></center><p></p></th>
                                            <th><center><img src="/imagenes/textos/cantidad.png" /></center><p></p></th>
                                        </tr>
                                    </thead>
                                    <tbody>
<?php
  $count_rows = 0;
  $sql_select = mysql_query("SELECT * FROM log_transacciones WHERE Usuario LIKE '%".$_SESSION['USER:NAME']."%' ORDER BY ID DESC ");
  while($trans = mysql_fetch_array($sql_select))
  {
    $count_rows++;
?>
                                    <tr>
                                            <td><center><p style="font-size:13px"><?php echo $trans['Fecha']; ?></center></td>
                                            <td><center><p style="font-size:13px">(<i>CTA <?php echo $player['ID']?>165-<?php echo $player['Numero']?>6<?php echo $player['ID']?>84</i>)</center></td>
                                            <td><center><p style="font-size:13px"><?php echo $trans['Destino']; ?></center></td>
                                            <td><center><p style="color:red;font-size:13px">-$<?php echo number_format($trans['Cantidad'],0,",","."); ?></center></td>
                                            </td>
                                        </tr>
<?php
  }
?>
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
sin imagen de perfil

Unir ambas querys en una única table

Publicado por Daniel (43 intervenciones) el 07/02/2016 19:27:37
entiendo que quieres esto?

1
$sql_select = mysql_query("SELECT * FROM log_transacciones WHERE Usuario LIKE '%".$_SESSION['USER:NAME']."%' OR Destino LIKE '%".$_SESSION['USER:NAME']."%' ORDER BY ID DESC ");
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar