Pagina 1 di 3 1 2 3 ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 22

Discussione: visualizza film

  1. #1

    visualizza film

    Salve a tutti ragazzi, il seguente codice permette di visualizzare tutti i film che sono presenti nel database, il problema e che quando clicco sulla pagina successiva mi visualizza sempre la stessa pagina. Da che cosa dipende ? Sarà che devo dichiarare la costante tot nella select ? E se si come fare ! Ecco il codice:

    <?
    include("config.PHP");
    include("selezione.PHP");
    $tot=0;

    if (!isset($start) OR $start<0){
    $start=0;
    $step=20;
    }

    $query=mysql_query("SELECT * FROM `film` order by titolo asc LIMIT $start,$step ") OR DIE ("select Non Riuscita");





    ?>







    <html>
    <body>



    <div align="center">


    <font color="#000099" size="4" face="Arial, Helvetica, sans-serif">Elenco
    Film </font></p>
    </div>
    <div align="center"></div>
    <div align="center">
    <table width="800" border="0" cellspacing="1" cellpadding="0">
    <tr bordercolor="#FFFFFF" bgcolor="#000099">
    <td width="6"><font face="Arial, Helvetica, sans-serif" size="2" color="#FFFFFF">numero</font></td>
    <td width="200"><font face="Arial, Helvetica, sans-serif" size="2" color="#FFFFFF">nome</font></td>
    <td width="50"><font face="Arial, Helvetica, sans-serif" size="2" color="#FFFFFF">genere</font></td>
    <td width="220"><font face="Arial, Helvetica, sans-serif" size="2" color="#FFFFFF">attori</font></td>


    </tr>
    <?


    while ($row=mysql_fetch_array($query))
    {
    echo "<tr bgcolor='#CCCCCC'>";
    echo "<td width='6'> <font face='Arial, Helvetica, sans-serif' size='2' color='#000099'>$row[id]</font></td>";
    echo "<td width='200'> <font face='Arial, Helvetica, sans-serif' size='2' color='#000099'> $row[titolo]</font></td>";
    echo "<td width='50'><font face='Arial, Helvetica, sans-serif' size='2' color='#000099'> $row[genere]</font></td>";
    echo "<td width='220'><font face='Arial, Helvetica, sans-serif' size='2' color='#000099'> $row[attore1],$row[attore2],$row[attore3]</font></td>";



    echo"</tr>";
    }

    ?>
    </table>




    </div>
    <div align="center">
    <table width=37% border=0 align="center">
    <tr>
    <td width=29% align=left>
    <?

    if ($start>0)
    {
    $start_back = $start - $step;
    echo "<a href=visualizza.php?start=$start_back>precedenti</a>";
    }

    ?>
    <div align="right"></div></td>
    <?

    $query1=mysql_query("SELECT count(*) AS tot FROM film ");

    $row=mysql_fetch_array($query1);


    $pages=intval(($row["tot"]-1) / $step)+1;

    ?>
    <td width=38% align=center>
    <?

    for ($i=0; $i<$pages AND $i<20; $i++)
    { $start_page = $i * $step;
    echo "<a href=visualizza.php?start=$start_page>" . ($i+1) . "</a> ";
    }

    ?>
    </td>
    <td width=33%>
    <?

    if ($start + $step < $row["tot"])
    { $start_next = $start + $step;
    echo "<a href=visualizza.php?start=$start_next>successivi</a>";
    }

    ?>
    </td>
    </tr>
    </table>



    </div>








    </body>
    </html>
    Roberto Dungino

  2. #2
    Moderatore di Server Apache L'avatar di marketto
    Registrato dal
    Sep 2001
    Messaggi
    5,858
    probabilmente hai il register global settato ad off nel php.ini, di conseguenza per poter passare le variabili tramite querystring devi usare l'array $_GET:
    codice:
    $start diventa $_GET['start']




    per maggiori info:
    http://forum.html.it/forum/showthrea...hreadid=245215
    think simple think ringo

  3. #3
    Ho fatto come dici tu ma adesso mi dà il seguente errore:
    Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in c:\programmi\easyphp1-8\www\database_film\visualizza.php on line 76




    76: echo "<a href=visualizza.php?$_GET['start']=$start_page>" . ($i+1) . "</a> ";







    <?
    include("config.PHP");
    include("selezione.PHP");
    $tot = (isset($_GET['tot']))?$_GET['tot']:'0';



    if (!isset($start) OR $start<0)
    $start=0;
    $step=20;

    $query=mysql_query("SELECT * FROM `film` order by titolo asc LIMIT $start,$step ") OR DIE ("select Non Riuscita");





    ?>







    <html>
    <body>



    <div align="center">


    <font color="#000099" size="4" face="Arial, Helvetica, sans-serif">Elenco
    Film </font></p>
    </div>
    <div align="center"></div>
    <div align="center">
    <table width="800" border="0" cellspacing="1" cellpadding="0">
    <tr bordercolor="#FFFFFF" bgcolor="#000099">
    <td width="6"><font face="Arial, Helvetica, sans-serif" size="2" color="#FFFFFF">numero</font></td>
    <td width="200"><font face="Arial, Helvetica, sans-serif" size="2" color="#FFFFFF">nome</font></td>
    <td width="50"><font face="Arial, Helvetica, sans-serif" size="2" color="#FFFFFF">genere</font></td>
    <td width="220"><font face="Arial, Helvetica, sans-serif" size="2" color="#FFFFFF">attori</font></td>


    </tr>
    <?


    while ($row=mysql_fetch_array($query))
    {
    echo "<tr bgcolor='#CCCCCC'>";
    echo "<td width='6'> <font face='Arial, Helvetica, sans-serif' size='2' color='#000099'>$row[id]</font></td>";
    echo "<td width='200'> <font face='Arial, Helvetica, sans-serif' size='2' color='#000099'> $row[titolo]</font></td>";
    echo "<td width='50'><font face='Arial, Helvetica, sans-serif' size='2' color='#000099'> $row[genere]</font></td>";
    echo "<td width='220'><font face='Arial, Helvetica, sans-serif' size='2' color='#000099'> $row[attore1],$row[attore2],$row[attore3]</font></td>";



    echo"</tr>";
    }

    ?>
    </table>




    </div>
    <div align="center">
    <table width=37% border=0 align="center">
    <tr>
    <td width=29% align=left>
    <?

    if ($start>0)
    {
    $start_back = $start - $step;
    echo "<a href=visualizza.php?$_GET['start']=$start_back>precedenti</a>";
    }

    ?>
    <div align="right"></div></td>
    <?

    $query1=mysql_query("SELECT count(*) AS tot FROM film ");

    $row=mysql_fetch_array($query1);


    $pages=intval(($row["tot"]-1) / $step)+1;

    ?>
    <td width=38% align=center>
    <?

    for ($i=0; $i<$pages AND $i<20; $i++)
    { $start_page = $i * $step;
    echo "<a href=visualizza.php?$_GET['start']=$start_page>" . ($i+1) . "</a> ";
    }

    ?>
    </td>
    <td width=33%>
    <?

    if ($start + $step < $row["tot"])
    { $start_next = $start + $step;
    echo "<a href=visualizza.php?$_GET['start']=$start_next>successivi</a>";
    }

    ?>
    </td>
    </tr>
    </table>



    </div>








    </body>
    </html>
    Roberto Dungino

  4. #4
    Moderatore di Server Apache L'avatar di marketto
    Registrato dal
    Sep 2001
    Messaggi
    5,858
    devi usare le parentesi graffe:
    codice:
    echo "<a href=visualizza.php?{$_GET['start']}=$start_page>" . ($i+1) . "</a> ";
    think simple think ringo

  5. #5
    Scusa hai un sito di cinema? Posso chiederti l'url? Se preferisci anche in pvt.

    Ne ho uno anche io, è quello in firma e vorrei chederti un paio di cose.

  6. #6
    no non ho un sito di cinema è un programma per gestire i miei film in dvd !
    Roberto Dungino

  7. #7
    Adesso mi visualizza la pagina, ma accanto ai numeri di pagina ese il Notice:

    Notice: Undefined index: start in c:\programmi\easyphp1-8\www\database_film\visualizza.php on line 96
    Roberto Dungino

  8. #8
    Moderatore di Server Apache L'avatar di marketto
    Registrato dal
    Sep 2001
    Messaggi
    5,858
    Originariamente inviato da dungino
    Adesso mi visualizza la pagina, ma accanto ai numeri di pagina ese il Notice:

    Notice: Undefined index: start in c:\programmi\easyphp1-8\www\database_film\visualizza.php on line 96
    prima di richiamare una variabile tramite $_GET devi controllare che essa esista:
    www.php.net/isset
    think simple think ringo

  9. #9
    "if (!isset($start) OR $start<0)
    $start=0;
    $step=20;
    "

    ma questo io lo faccio, richiamo sempre la stessa pagina ma gli invio parametri diversi! Non capisco dove sia il problema.
    Roberto Dungino

  10. #10
    Moderatore di Server Apache L'avatar di marketto
    Registrato dal
    Sep 2001
    Messaggi
    5,858
    quel notice indica che l'indice dell'array associato che provi a richiamare non esiste...ti faccio un'esempio:
    codice:
    <?php
    echo $_GET['start']; 
    ?>
    // Notice: Undefined index: start in e:\root\prova.php on line 2

    codice:
    <?php
    $_GET['start'] = 1;
    echo $_GET['start']; 
    // 1
    ?>

    codice:
    <?php
    error_reporting( E_ALL );
    if ( isset( $_GET['start'] ) )
    	echo $_GET['start']; 
    else
    	echo 'la variabile richiesta non esiste';
    ?>
    //la variabile richiesta non esiste
    think simple think ringo

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 © 2024 vBulletin Solutions, Inc. All rights reserved.