Visualizzazione dei risultati da 1 a 9 su 9

Discussione: Stampa risultati

  1. #1

    Stampa risultati

    avrei bisogno di uno script ke i risultati del mio select sn + di 3 (e multipli di 3) mi crea un'altra riga della mia tabella e mi và a capo....



    Come posso fare????



    Grazie in anticipo....

  2. #2
    Prima utilizzavo questo...


    Codice PHP:
    $query "select * from.......";
    $result mysql_query ($query) or die .....;
    $numero_righe=mysql_num_rows($result);

    echo 
    "<table border=.......";
                
    while(
    $a_row=mysql_fetch_array($result))
    {

      {
      
    $i+=1;

        if ((
    $i%3)!=1)
        {
        echo 
    "<td width=......>";
        echo 
    ".....</td>";
        }
        else
        {
        echo 
    "</tr><tr><td width=......";
        echo 
    ".....</td>";
        }

      }



    ma ora ottengo l'errore


    Codice PHP:
    NoticeUndefined variablei in......... 

    Come posso risolvere???

  3. #3
    Utente di HTML.it
    Registrato dal
    Aug 2002
    Messaggi
    8,013
    prova qualcosa del genere

    codice:
    <?php
      $my_array = array("Ciao", "Mamma", "Guarda", "Come", "Mi", "Diverto", "...", "Questo", "Esemprio", "Fa", "Proprio", "Pena,", "Scusate!");
      $divide = 3; ?>
    
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>Untitled Document</title>
    </head>
    
    <body>
    <table border="1" cellpadding="10" cellspacing="10">
    <?php
      for ($j = 0; $j <= floor(count($my_array)/$divide); $j++) { ?>
        <tr>
    	<?php 
    	  for ($i = $j*$divide; $i < ($j+1)*$divide && $i < count($my_array); $i++) { ?>
    	    <td bordercolor="#999999" ><?php echo($my_array[$i]);?></td>
    	  <?php } ?>	
    	</tr> <?php } ?>
    </table>
    
    </body>
    </html>
    Dove $my_array è l'array contenente i dati che vuoi mostrare, $divide è il numero di dati per riga.
    <´¯)(¯`¤._)(¯`»ANDREA«´¯)(_.¤´¯)(¯`>
    "The answer to your question is: welcome to tomorrow"

  4. #4
    ho modificato il tutto ksì;

    ---------------------------------------------------------

    $query = "select * from.......";
    $result = mysql_query ($query) or die .....;
    $numero_righe=mysql_num_rows($result);

    echo "<center><table border=2 style=\"border-collapse: collapse\" width=480><center>";
    while($a_row=mysql_fetch_array($result))
    {
    $my_array = array($a_row['photo']);


    $divide = 3;


    for ($j = 0; $j <= floor(count($my_array)/$divide); $j++)
    {
    print "<tr>";

    for ($i = $j*$divide; $i < ($j+1)*$divide && $i < count($my_array); $i++)
    {
    print "<td bordercolor=\"#999999\">";
    print ($my_array[$i]);
    print "</td>";
    }

    print "</tr>";
    }
    }


    ---------------------------------------------------------

    ma nn funge.....

  5. #5
    o per meglio dire.....mi crea tante righe per quanti sono i risultati....


    secondo me l'errore è in


    Codice PHP:
    $my_array = array($a_row['photo']); 

    può essere????

  6. #6
    Utente di HTML.it
    Registrato dal
    Aug 2002
    Messaggi
    8,013
    Non funziona perché il fetch che fai

    codice:
    while($a_row=mysql_fetch_array($result))
    mysql_fetch_array carica una riga di result alla volta, non l'intera colonna 'photo', per quello lo script non funziona.
    <´¯)(¯`¤._)(¯`»ANDREA«´¯)(_.¤´¯)(¯`>
    "The answer to your question is: welcome to tomorrow"

  7. #7
    e come posso risolvere????

  8. #8
    Utente di HTML.it
    Registrato dal
    Aug 2002
    Messaggi
    8,013
    prova così:

    codice:
    <table border="1" cellpadding="10" cellspacing="10">
      <tr><?php
        $counter = 0;
    	while($a_row=mysql_fetch_array($result)) { 
    	  if ($counter == $divide) { 
    	   $counter = 0;
    	 ?></tr>
    	 <tr><?php } ?><td><?php echo($a_row['photo']); $counter++; ?></td><?php } ?>          
      </tr>
    </table>
    <´¯)(¯`¤._)(¯`»ANDREA«´¯)(_.¤´¯)(¯`>
    "The answer to your question is: welcome to tomorrow"

  9. #9
    Grazie Andrea1979 funziona correttamente, sei 1 grande



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.