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

    elencare dati prelevati database

    Salve ragazzi, ho questa funzione, vorrei elencare i dati contenuti in un database, però cosi mi da solo l'ultimo valore inserito in tabella, ecco il codice:
    Codice PHP:
    public function informazioni() { require_once('includes/config.php'); $query "SELECT * FROM page"$res = @mysql_query($query) or die (mysql_error ()); $i 0; while ($row = @mysql_fetch_array($res)) { $tit $row['page_title']; $tit ucwords($tit); $ind $row['indirizzo']; }  echo <<<INFO <table width="179" border="0" cellspacing="2" cellpadding="0">             <tr>               <td height="200" align="left" valign="top" id="informazioni"><table width="160" border="0" cellspacing="0" cellpadding="0">                 <tr>                   <td align="left" valign="top" id="contenuto_info">[url="$ind"]$tit[/url]
    </
    td>                 </tr>               </table></td>             </tr>           </tableINFO; } 
    Grazie

  2. #2
    Utente di HTML.it
    Registrato dal
    Feb 2008
    Messaggi
    209
    cosi penso che vado bene
    il while lo devi chiudere dopo che hai finito di stampare tutto se no prende l'ultimo valore come succede a te

    <?php
    public function informazioni() {
    require_once('includes/config.php');
    $query = "SELECT SELECT * FROM page";
    $res = @mysql_query($query) or die (mysql_error ());
    $i = 0;
    while ($row = @mysql_fetch_array($res))
    {
    $tit = $row['page_title'];
    $tit = ucwords($tit);
    $ind = $row['indirizzo'];

    ?>
    <table width="179" border="0" cellspacing="2" cellpadding="0">
    <tr>
    <td height="200" align="left" valign="top" id="informazioni">
    <table width="160" border="0" cellspacing="0" cellpadding="0">
    <tr>
    <td align="left" valign="top" id="contenuto_info"><?php echo $tit ?>

    </td>
    </tr>
    </table>
    </td>
    </tr>
    </table>
    <?php }?>

  3. #3
    Mi dici che senso ha stampare una tabella dentro un'altra tabella come fai tu? e la variabile $i a che serve?

    cmq secondo me dovresti fare così, almeno non stampi 30000 tabelle.


    Codice PHP:
    <?php

    require_once('includes/config.php'); 

    public function 
    informazioni() {
        
        
    $query "SELECT * FROM page";
        
    $res = @mysql_query($query) or die (mysql_error ());

        
    ?>
        <table width="179" border="0" cellspacing="2" cellpadding="0">
        <?php

        
    while ($row = @mysql_fetch_array($res)) {

            
    $tit $row['page_title'];
            
    $tit ucwords($tit);
            
    $ind $row['indirizzo'];

            
    ?>
            <tr>
                <td>[url="<?php echo $ind?>"]<?php echo $tit?>[/url]</td>
            </tr>
            <?php
        
    }

        
    ?>
        </table>

    <?php
    }
    ?>

  4. #4
    Si ragazzi, potrebbero andare bene, ma io sto usando funzioni heredoc, e come ho potuto capire in heredoc non posso sviluppare php.
    Così non mi funziona!

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.