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

    Più cicli while nella stessa pag.

    Ciao a tutti.
    Ho una pagina con più elenchi, staccati uno dall'altro e dognuno fatto funzionare con while...

    Codice PHP:
    <span style="font-size: 250%;"><font color="#FF0000"><center>Oggetti</center></font></span>


    <font face='verdana' size='1'><center>[b][url="scheda.php"]Scheda[/url][/b]</center>

    <center><table border=1 width='100%'><tr width='550'><td width='100' bgcolor='green'><font color='white' size='1'><center>[b]Oggetto[/b]</center></font></td><td width='80' bgcolor='green'><font color='white' size='1'><center>[b]Immagine[/b]</center></font></td><td bgcolor='green'><font color='white' size='1'><center>[b]Descrizione[/b]</center></font></td><td width='110' bgcolor='green'><font color='white' size='1'><center>[b]Opzioni[/b]</center></font></td></tr>
    <?php
    $query 
    "SELECT * FROM  borsa  WHERE Nick='$row[Nick]' ORDER BY `ID` ASC";
    $result mysql_query($query$db);
    while (
    $row mysql_fetch_array($result))
    echo 
    "<tr><TD width=100><font color=#00cc00 size='1'><center>[b]$row[Oggetto][/b]</center></font></td><td width='80' bgcolor='black'><center><img src=/img/$row[Img] width='80' height='80'></td><TD><center>[b]<font color='#00cc00' size='1'>$row[Descrizione]</center></td><TD width=110><font size='1'><center>[b][url='passa_oggetto.php?ID=$row[ID]']Passa[/url]

    [url='getta.php?ID=
    $row[ID]']Getta[/url][/b]</center></td></tr></table></center>";
    ?>
    ...questo èra une dei cicli della pag. Ora se ne metto un altro identico sotto, il primo ciclo mi funziona perfettamente, il secondo invece no; non mi elenca i dati selezionati. Come mai? grazie
    http://codecanyon.net/category/all?ref=Manuelandro
    And I bet she told a million people that she'd stay in touch, Well all the little promises they dont mean much,When theres
    memories to be made

  2. #2
    prima di passare al secondo while devi resettare mysql_fetch_array e riportare il puntatore a zero. Usa mysql_data_seek.

    http://it.php.net/manual/it/function...-data-seek.php




    ps.: Ma non hai il tasto del return sul tuo PC? Perche' fai righe cosi' lunghe?

    Il silenzio è spesso la cosa migliore. Pensa ... è gratis.

  3. #3
    Codice PHP:
    $query "SELECT * FROM borsa";
    $result mysql_query($query$db);
    while(
    $row mysql_fetch_array($result)) {
    if (!
    mysql_data_seek($result$i)) {
    echo
    "ecc"
    ???
    http://codecanyon.net/category/all?ref=Manuelandro
    And I bet she told a million people that she'd stay in touch, Well all the little promises they dont mean much,When theres
    memories to be made

  4. #4
    [supersaibal]Originariamente inviato da Manuelandro
    Codice PHP:
    $query "SELECT * FROM borsa";
    $result mysql_query($query$db);
    while(
    $row mysql_fetch_array($result)) {
    if (!
    mysql_data_seek($result$i)) {
    echo
    "ecc"
    ??? [/supersaibal]
    ?????????

    lo saprai tu quello che devi fare... quello che hai postato ha zero significato. Fai vedere cosa intendi per due cicli while.


    Il silenzio è spesso la cosa migliore. Pensa ... è gratis.

  5. #5
    Codice PHP:
    $query "SELECT * FROM borsa";$result mysql_query($query$db);
    while(
    $row mysql_fetch_array($result)) {
    echo
    "<table><tr><td>$row[oggetto]</td><td>$row[costo]</td></tr>";
    </
    table>

    $query "SELECT * FROM armi";$result mysql_query($query$db);
    while(
    $wer mysql_fetch_array($result)) {
    echo
    "<table><tr><td>$wer[arma]</td><td>$wer[costo]</td></tr>";
    </
    table>

    $query "SELECT * FROM pozioni";$result mysql_query($query$db);
    while(
    $cos mysql_fetch_array($result)) {
    echo
    "<table><tr><td>$cos[pozione]</td><td>$cos[costo]</td></tr>";
    </
    table
    ecco...come stanno nela stessa pagina.
    http://codecanyon.net/category/all?ref=Manuelandro
    And I bet she told a million people that she'd stay in touch, Well all the little promises they dont mean much,When theres
    memories to be made

  6. #6
    non li chiudi mai i cicli while?

    Il silenzio è spesso la cosa migliore. Pensa ... è gratis.

  7. #7
    non mi èra mai servito chiuderli. Quindi non l'ho mai fatto e mai visto come si faceva!
    http://codecanyon.net/category/all?ref=Manuelandro
    And I bet she told a million people that she'd stay in touch, Well all the little promises they dont mean much,When theres
    memories to be made

  8. #8
    codice:
    $query = "SELECT * FROM borsa";
    $result = mysql_query($query, $db) or die(mysql_error());
    
    while($row = mysql_fetch_array($result)) {
    
    echo "<table><tr><td>$row[oggetto]</td> <td>$row[costo]</td></tr></table>";
    }  // chiudi il while
    Hai anche la stringa </table> fuori dall'echo che ti causa un parser error.

    Converrebbe mettere solo una istruzione php per riga altrimenti e' poco leggibile. per esempio:
    Codice PHP:
    $query "SELECT * FROM borsa";$result mysql_query($query$db); 
    E meglio:
    Codice PHP:
    $query "SELECT * FROM borsa";
    $result mysql_query($query$db) or die(mysql_error()); 


    Il silenzio è spesso la cosa migliore. Pensa ... è gratis.

  9. #9
    ah ma tu intendi } per chiudere il ciclo?? si quello certo che lo faccio!!
    http://codecanyon.net/category/all?ref=Manuelandro
    And I bet she told a million people that she'd stay in touch, Well all the little promises they dont mean much,When theres
    memories to be made

  10. #10
    cmq grazie
    http://codecanyon.net/category/all?ref=Manuelandro
    And I bet she told a million people that she'd stay in touch, Well all the little promises they dont mean much,When theres
    memories to be made

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.