Pagina 1 di 2 1 2 ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 15
  1. #1

    Dividere ciclo while di un DB su più pagine

    Ciao a tutti,
    sono 1 pò nei casini con questo codice:

    Codice PHP:
    <?php 
    include('../includes/config.php');
    include(
    '../includes/opendb.php');

    $result mysql_query("SELECT * FROM `darkuniverse_user` ORDER BY `darkuniverse_user`.`punti` DESC"); 

    echo 
    "<table width='300' table border='1' cellpadding='0' cellspacing='0' style='border-collapse: collapse' bordercolor='black'>
    <tr>
        <td background='../images/classifica_top.png'><p class='Stile2'>Nome Utente</p></td>
        <td background='../images/classifica_top.png'><p class='Stile2'>Punteggio</p></td>
        <td background='../images/classifica_top.png'><p class='Stile2'>Livello</p></td>
      </tr>"
    ;

    while(
    $myrow mysql_fetch_array($result)) 

    echo 
    '<tr>
        <td background="../images/classifica_bg.png" class="classifica">'
    .$myrow["nomeutente"].'</td><td background="../images/classifica_bg.png" class="classifica">'.$myrow["punti"].'</td><td background="../images/classifica_bg.png" class="classifica">'.$myrow["livello"].'</td>';
    echo 
    '</tr>';
    }
    echo 
    '</table>';

    ?>
    Il mio scopo è di dividere questa tabella che si crea con tutti gli utenti iscritti, punteggio e livello su più pagine!
    Come posso fare??

    Grazie in anticipo a tutti!
    Cerco Sviluppatori Flash: http://forum.html.it/forum/showthread.php?threadid=1418906

  2. #2
    in questo esempio vedrai i primi 10 record; cliccando in fondo sul pulsante >> la pagina verrà ricaricata e mostrerà i seguenti 10 grazie al valore della variabile $pos passata alla pagina stessa che viene immesso nella quwery sql col parametro aggiuntivo LIMIT $pos, 10 che significa "mostra 10 record apartire dla numero $pos".
    Noterai prue la riga if $pos<100 che visualizzerà i record utenti se sono, ad esempio 100

    Codice PHP:
    <html>
    <head><title></title></head>
    <body>
    <?
    $users 
    100;
    $pos $_REQUEST['pos'];
    if (
    $pos<100) {
    echo 
    "<form id=\"x\" method=\"post\" action=\"".$_SERVER['PHP_SELF']."&pos=$pos".">";
    include(
    '../includes/config.php');
    include(
    '../includes/opendb.php');
    $result mysql_query("SELECT * FROM `darkuniverse_user` ORDER BY `darkuniverse_user`.`punti` DESC LIMIT $pos,10");

    echo 
    "<table width='300' table border='1' cellpadding='0' cellspacing='0' style='border-collapse: collapse' bordercolor='black'>
    <tr>
        <td background='../images/classifica_top.png'><p class='Stile2'>Nome Utente</p></td>
        <td background='../images/classifica_top.png'><p class='Stile2'>Punteggio</p></td>
        <td background='../images/classifica_top.png'><p class='Stile2'>Livello</p></td>
      </tr>"
    ;

    while(
    $myrow mysql_fetch_array($result))
    {
    echo 
    '<tr>
        <td background="../images/classifica_bg.png" class="classifica">'
    .$myrow["nomeutente"].'</td><td background="../images/classifica_bg.png" class="classifica">'.$myrow["punti"].'</td><td background="../images/classifica_bg.png" class="classifica">'.$myrow["livello"].'</td>';
    echo 
    '</tr>';
    }
    echo 
    "<tr><td colspan=\"3\"><input type=\"submit\" value=\">>\" /></td></tr>";
    echo 
    '</table>'
    echo 
    "</form>";

    ?>
    </body>
    </html>

  3. #3
    ...c'è 1 ciclo IF aperto nelle prime righe del codice che poi non viene chiuso... la pagina non viene caricata xk non è kiuso il ciclo.. dove devo mettere } ???
    Cerco Sviluppatori Flash: http://forum.html.it/forum/showthread.php?threadid=1418906

  4. #4
    piccola disattenzione..prova cos'

    Codice PHP:
    <html>
    <head><title></title></head>
    <body>
    <?
    $users 
    100;
    $pos $_REQUEST['pos'];
    if (
    $pos<100) {
    echo 
    "<form id=\"x\" method=\"post\" action=\"".$_SERVER['PHP_SELF']."&pos=$pos"."\">";
    include(
    '../includes/config.php');
    include(
    '../includes/opendb.php');
    $result mysql_query("SELECT * FROM `darkuniverse_user` ORDER BY `darkuniverse_user`.`punti` DESC LIMIT $pos,10");

    echo 
    "<table width='300' table border='1' cellpadding='0' cellspacing='0' style='border-collapse: collapse' bordercolor='black'>
    <tr>
        <td background='../images/classifica_top.png'><p class='Stile2'>Nome Utente</p></td>
        <td background='../images/classifica_top.png'><p class='Stile2'>Punteggio</p></td>
        <td background='../images/classifica_top.png'><p class='Stile2'>Livello</p></td>
      </tr>"
    ;

    while(
    $myrow mysql_fetch_array($result))
    {
    echo 
    '<tr>
        <td background="../images/classifica_bg.png" class="classifica">'
    .$myrow["nomeutente"].'</td><td background="../images/classifica_bg.png" class="classifica">'.$myrow["punti"].'</td><td background="../images/classifica_bg.png" class="classifica">'.$myrow["livello"].'</td>';
    echo 
    '</tr>';
    }
    echo 
    "<tr><td colspan=\"3\"><input type=\"submit\" value=\">>\" /></td></tr>";
    echo 
    '</table>';
    echo 
    "</form>";
    }
    ?>
    </body>
    </html>

  5. #5
    visualizzo solo il tasto con la freccetta >>
    Cerco Sviluppatori Flash: http://forum.html.it/forum/showthread.php?threadid=1418906

  6. #6
    oggi sò accecà..ricopia il listato precedente e modificato...

  7. #7
    nada... viene solo la >>
    Cerco Sviluppatori Flash: http://forum.html.it/forum/showthread.php?threadid=1418906

  8. #8
    questo codice quasi funziona:

    Codice PHP:
    <? 
    $users 
    100
    $pos $_REQUEST['pos']; 
    if (
    $pos<100) { 
    echo 
    "<form id=\"x\" method=\"post\" action=\"".$_SERVER['PHP_SELF']."?pos=$pos"."\">"
    include(
    '../includes/config.php'); 
    include(
    '../includes/opendb.php'); 
    $result mysql_query("SELECT * FROM `darkuniverse_user` ORDER BY `darkuniverse_user`.`punti` DESC LIMIT $pos,10"); 

    echo 
    "<table width='300' table border='1' cellpadding='0' cellspacing='0' style='border-collapse: collapse' bordercolor='black'> 
    <tr> 
        <td background='../images/classifica_top.png'><p class='Stile2'>Nome Utente</p></td> 
        <td background='../images/classifica_top.png'><p class='Stile2'>Punteggio</p></td> 
        <td background='../images/classifica_top.png'><p class='Stile2'>Livello</p></td> 
      </tr>"


    while(
    $myrow mysql_fetch_array($result)) 

    echo 
    '<tr> 
        <td background="../images/classifica_bg.png" class="classifica">'
    .$myrow["nomeutente"].'</td><td background="../images/classifica_bg.png" class="classifica">'.$myrow["punti"].'</td><td background="../images/classifica_bg.png" class="classifica">'.$myrow["livello"].'</td>'
    echo 
    '</tr>'

    echo 
    "<tr><td colspan=\"3\"><input type=\"submit\" value=\">>\" /></td></tr>"
    echo 
    '</table>'
    echo 
    "</form>"

    ?>

    se come indirizzo x aprire la pagina faccio classifica.php?pos=1

    si vedono i primi 10 in classifica poi xò il tasto con la freccia nn va... ma semplicemente apre d nuovo la pagina classifica.php?pos=1
    Cerco Sviluppatori Flash: http://forum.html.it/forum/showthread.php?threadid=1418906

  9. #9
    ormai è questione di orgoglio..così deve andare!!!

    Codice PHP:
    <?
    $pos 
    $_REQUEST['pos'];
    if (
    $pos<100) {
    $nextPos $pos 10;
    $pos++;
    echo 
    "<form id=\"x\" method=\"post\" action=\"".$_SERVER['PHP_SELF']."?pos=$nextPos"."\">";
    include(
    '../includes/config.php');
    include(
    '../includes/opendb.php');
    $result mysql_query("SELECT * FROM `darkuniverse_user` ORDER BY `darkuniverse_user`.`punti` DESC LIMIT $pos,10");

    echo 
    "<table width='300' table border='1' cellpadding='0' cellspacing='0' style='border-collapse: collapse' bordercolor='black'>
    <tr>
        <td background='../images/classifica_top.png'><p class='Stile2'>Nome Utente</p></td>
        <td background='../images/classifica_top.png'><p class='Stile2'>Punteggio</p></td>
        <td background='../images/classifica_top.png'><p class='Stile2'>Livello</p></td>
      </tr>"
    ;

    while(
    $myrow mysql_fetch_array($result))
    {
    echo 
    '<tr>
        <td background="../images/classifica_bg.png" class="classifica">'
    .$myrow["nomeutente"].'</td><td background="../images/classifica_bg.png" class="classifica">'.$myrow["punti"].'</td><td background="../images/classifica_bg.png" class="classifica">'.$myrow["livello"].'</td>';
    echo 
    '</tr>';
    }
    echo 
    "<tr><td colspan=\"3\"><input type=\"submit\" value=\">>\" /></td></tr>";
    echo 
    '</table>';
    echo 
    "</form>";
    }
    ?>

  10. #10
    ok... ho risolto da solo modificando 1 pò il tuo codice:

    Codice PHP:
     <? 
    $users 
    100
    $page $_REQUEST['page'];
    if (
    $page<100) { 
    include(
    '../includes/config.php'); 
    include(
    '../includes/opendb.php'); 
    $result mysql_query("SELECT * FROM `darkuniverse_user` ORDER BY `darkuniverse_user`.`punti` DESC LIMIT $page,30"); 

    echo 
    "<table width='300' table border='1' cellpadding='0' cellspacing='0' style='border-collapse: collapse' bordercolor='black'> 
    <tr> 
        <td background='../images/classifica_top.png'><p class='Stile2'>Nome Utente</p></td> 
        <td background='../images/classifica_top.png'><p class='Stile2'>Punteggio</p></td> 
        <td background='../images/classifica_top.png'><p class='Stile2'>Livello</p></td> 
      </tr>"


    while(
    $myrow mysql_fetch_array($result)) 

    echo 
    '<tr> 
        <td background="../images/classifica_bg.png" class="classifica">'
    .$myrow["nomeutente"].'</td><td background="../images/classifica_bg.png" class="classifica">'.$myrow["punti"].'</td><td background="../images/classifica_bg.png" class="classifica">'.$myrow["livello"].'</td>'
    echo 
    '</tr>'

    $add="29";
    $page=$page+$add;
    echo 
    '<tr><td background="../images/classifica_top.png"><a href=classifica2.php?page='.$page.'>Avanti</a></td></tr>';
    echo 
    '</table>'



    ?>

    Mi servirebbe aggiungere una colonna alla tabella con scirtta la posizione del giocatore in classifica... come faccio?
    Cerco Sviluppatori Flash: http://forum.html.it/forum/showthread.php?threadid=1418906

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.