Visualizzazione dei risultati da 1 a 2 su 2
  1. #1

    [PHP MySQL] Raggruppare record

    Mi psiego meglio, ho uno script che mi prende le info del navigatore e me le mette nel db, ora quando le estraggo per vederle mi fa una lunga lista che in se non é sbagliato, io vorrei poter tirare fuori per ogni utente in base all'id solo l'ultimo record inserito:


    ora mi esce cosi:

    User: admin
    Host: lbalbal
    ip: 123.123.123.123
    uri: pagina.php

    User: admin
    Host: lbalbal
    ip: 123.123.123.123
    uri: pagina2.php

    User: admin
    Host: lbalbal
    ip: 123.123.123.123
    uri: pagina3.php

    User: test
    Host: sfssf
    ip: 125.555.123.123
    uri: paginauser.php

    User: test
    Host: sfssf
    ip: 125.555.123.123
    uri: paginauser4.php


    io vorrei prendere sempre l'ultimo record cioé l'ultima azione che ha fatto!

    User: admin
    Host: lbalbal
    ip: 123.123.123.123
    uri: pagina3.php

    User: test
    Host: sfssf
    ip: 125.555.123.123
    uri: paginauser4.php


    Come posso fare?


    questo é il codice che ho fatto fin'ora!!

    Codice PHP:
    $sql_stats = "SELECT * FROM tbl_stats, tbl_login WHERE tbl_stats.lg_id = tbl_login.lg_id";
    $query_stats = mysql_query($sql_stats) or die (mysql_error());



    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    </head>

    <body>
    <table width="480" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td><div align="center">

        <span class="TestoIndicativo">
        Utenti Connessi</div>

        

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


    <table width="480" border="0" cellspacing="0" cellpadding="0">
    <?php while($result_stats mysql_fetch_assoc($query_stats)) {;?>
      <tr>
        <td width="100"><span class="TestoIndicativo">User</span></td>
        <td width="380"><span class="TestoIndicativo"><?php echo $result_stats['lg_usr'];?></span></td>
      </tr>
      <tr>
        <td><span class="TestoIndicativo">Host</span></td>
        <td><span class="TestoIndicativo"><?php echo $result_stats['sta_host'];?></span></td>
      </tr>
      <tr>
        <td><span class="TestoIndicativo">Agent</span></td>
        <td></td>
      </tr>
      <tr>
        <td colspan="2"><span class="TestoIndicativo"><?php echo $result_stats['sta_agent'];?></span></td>
      </tr>
      <tr>
        <td><span class="TestoIndicativo">Ip</span></td>
        <td><span class="TestoIndicativo"><?php echo $result_stats['sta_ip'];?></span></td>
      </tr>
      <tr>
        <td><span class="TestoIndicativo">Url</span></td>
        <td><span class="TestoIndicativo"><?php echo $result_stats['sta_url'];?></span></td>
      </tr>
      <tr>
        <td></td>
        <td></td>
      </tr>
      <tr>
        <td></td>
        <td></td>
      </tr>
      
      <?php };?>
    </table>




    </p>
    </body>
    </html>
    PHP THE BEST

  2. #2
    up
    PHP THE BEST

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.