• User Attivo

    @danny1975 said:

    Ciao, più che un while ti scrivo un for se per te va bene
    [php]
    $query = mysql_query("SELECT * FROM ddt WHERE id_cliente = '1'")
    or die("errore nella query;"mysql_error());
    for($i = 0; $i < mysql_num_rows($quey); $i++)
    {
    $rec = mysql_fetch_assoc($query);
    echo $rec['id'];
    }
    [/php]spero di esserti stato di aiuto
    Ciao

    mi da errore...

    <?
    function ddt($id){
    $obj=new sast1com();
    $obj->connessione();
    $row = mysql_query("select * from ddt where idcliente='$id'");
    or die("errore nella query;"mysql_error());
    for($i = 0; $i < mysql_num_rows($query); $i++)
    {
    $rec = mysql_fetch_assoc($query);
    echo $rec['id'];
    }
    ?>


  • User Attivo

    @peterminnow said:

    mi da errore...

    <?
    function ddt($id){
    $obj=new sast1com();
    $obj->connessione();
    $row = mysql_query("select * from ddt where idcliente='$id'");
    or die("errore nella query;"mysql_error());
    for($i = 0; $i < mysql_num_rows($query); $i++)
    {
    $rec = mysql_fetch_assoc($query);
    echo $rec['id'];
    }
    ?>
    Ciao, la prossima volta posta anche l'errore, comunque vedi che forse è da cambiare
    [PHP]$rec = mysql_fetch_assoc($query);[/PHP]
    con
    [PHP]$rec = mysql_fetch_assoc($row);[/PHP]
    ciao


  • User Attivo

    Wed Nov 30 13:35:44 2011] [error] [client 192.xxx.xxx.xxx] PHP Parse error: syntax error, unexpected T_LOGICAL_OR .....

    <?
    function ddt($id){
    $obj=new sast1com();
    $obj->connessione();
    $row = mysql_query("select * from ddt where idcliente='$id'");
    or die("errore nella query;"mysql_error());
    for($i = 0; $i < mysql_num_rows($query); $i++)
    {
    $rec = mysql_fetch_assoc($rec);
    echo $rec['id'];
    }
    ?>


  • User Attivo

    @peterminnow said:

    Wed Nov 30 13:35:44 2011] [error] [client 192.xxx.xxx.xxx] PHP Parse error: syntax error, unexpected T_LOGICAL_OR .....

    <?
    function ddt($id){
    $obj=new sast1com();
    $obj->connessione();
    $row = mysql_query("select * from ddt where idcliente='$id'");
    or die("errore nella query;"mysql_error());
    for($i = 0; $i < mysql_num_rows($query); $i++)
    {
    $rec = mysql_fetch_assoc($rec);
    echo $rec['id'];
    }
    ?>

    Non avevo visto cosa hai scritto, ```
    $rec = mysql_fetch_assoc($rec);

    è sbagliata, tra le parentesi devi inserire $row, il ; va tolto perchè la query finisce sotto
     
    Ciao, scusa togli gli apici in ```
    echo $rec['id'];
    

    inoltre prova la query con una costante tipo ```
    where idcliente='1'"

    e vedi se ti ritorna qualcosa, nel caso la risposta sia positiva, dovresti fare un controllo su $id, tipo fartelo stampare
    Ciao

  • User Attivo

    ...ma non sono pratico quanto te, mi da errore!


  • User Attivo

    @peterminnow said:

    ...ma non sono pratico quanto te, mi da errore!

    Ciao, comiciamo da capo, per tirare fuori una lista di nomi da una tabella bisogna fare un ciclo, quindi
    1 - elimina lo script che hai, anzi salvati la pagina potrebbe servirti più avanti
    avendo una tabella chiamata pippo con al suo interno un campo id_pippo ed uno nomi, possiamo estrarre tutto dal suo interno facendo in questo modo
    [php]
    $estrazione = mysql_query("select * from pippo")
    or die("errore nella query estrazione;".mysql_error());
    for($i = 0; $i < mysql_num_rows($estrazione); $i++)
    {
    $rec_estr = mysql_fetch_assoc($estrazione);
    echo $rec_estr[nomi];
    }
    [/php]
    mentre se devi estrarre un particolare nome in base ad una richiesta, la query va leggermente modificata
    [PHP]
    $estrazione = mysql_query("select * from pippo where id_pippo = '1'")
    or die("errore nella query estrazione;".mysql_error());
    $rec_estr = mysql_fetch_assoc($estrazione);
    echo $rec_estr[nomi];
    [/php]
    Adesso credo che il tuo problema sia un altro, se posti le tabelle interessate vediao di che si tratta, secondo me tu devi estrapolare dati da più tabelle e per fare ciò queste 2 soluzioni presentate non sono valide
    Ciao, con un po di pazienza si riesce


  • User Attivo

    si tratta di tirar fuori numero progressivo e dataemissione dei DDt emmessi ad uno specifico cliente con un suo" idcliente" che vado poi a visualizzare nei campi della fattura con qualcosa del tipo <? echo ddt($idcliente)?> e non tutta la lista dei dati!


  • User Attivo

    @peterminnow said:

    si tratta di tirar fuori numero progressivo e dataemissione dei DDt emmessi ad uno specifico cliente con un suo" idcliente" che vado poi a visualizzare nei campi della fattura con qualcosa del tipo <? echo ddt($idcliente)?> e non tutta la lista dei dati!

    Va be, allora va bene la seconda ipotesi
    ddt è la tua tabella
    1 è l'id_cliente della tabella ddt, per adesso provo con una costante
    [PHP]
    $estrazione = mysql_query("select * from ddt where id_cliente = '1'")
    or die("errore nella query estrazione;".mysql_error());
    $rec_estr = mysql_fetch_assoc($estrazione);
    echo $rec_estr[numero_progressivo];
    [/PHP]
    cosi dovrebbe andare bene, prova così e poi cercheremo di inserire $id_cliente
    ciao


  • User Attivo

    non ci sono errori in questo modo...ma come stampo i risultati?


  • User Attivo

    @peterminnow said:

    non ci sono errori in questo modo...ma come stampo i risultati?

    Scusa mi fai vedere cosa hai scritto
    perchè ti ho messo un echo nel codice
    ciao


  • User Attivo

    <?
    $obj=new sast1com();
    $obj->connessione();
    $estrazione = mysql_query("select * from ddt where idcliente = '1'")
    or die("errore nella query estrazione;".mysql_error());
    $rec_estr = mysql_fetch_assoc($estrazione);

    echo $rec_estr[progressivo];

    ?>


  • User Attivo

    @peterminnow said:

    <?
    $obj=new sast1com();
    $obj->connessione();
    $estrazione = mysql_query("select * from ddt where idcliente = '1'")
    or die("errore nella query estrazione;".mysql_error());
    $rec_estr = mysql_fetch_assoc($estrazione);

    echo $rec_estr[progressivo];

    ?>

    Metti gli apici in ['progressivo'] ciao


  • User Attivo

    non stampa nulla...ma senza errori


  • User Attivo

    @peterminnow said:

    non stampa nulla...ma senza errori
    Ciao, strano, ne ho provata una uguale alla tua e stampa
    [PHP]echo $rec_estr['progressivo']; [/PHP]
    Prova a postare la tabella


  • User Attivo

    ...di questa sessione

    <?
    function cliente($id){
    $obj=new sast1com();
    $obj->connessione();
    $dati=mysql_query("select * from clienti where id='$id'");
    while($array=mysql_fetch_array($dati)){
    return "$array[denominazione]<br>$array[indirizzo]<br> $array[cap] $array[citta] $array[provincia]";
    }
    }
    echo cliente($idcliente);
    ?>


  • User Attivo

    @peterminnow said:

    ...di questa sessione

    <?
    function cliente($id){
    $obj=new sast1com();
    $obj->connessione();
    $dati=mysql_query("select * from clienti where id='$id'");
    while($array=mysql_fetch_array($dati)){
    return "$array[denominazione]<br>$array[indirizzo]<br> $array[cap] $array[citta] $array[provincia]";
    }
    }
    echo cliente($idcliente);
    ?>

    Ciao, bene allora se funziona usa questa :vai:
    Ciao, ma molto strano dovrebbe funzionare anche l'altra, comunque è semplice modifica i camppi nella query e la lanci


  • User Attivo

    è proprio quello il problema se cambio il campo from in ddt ed il resto progressivo ecc. non sunziona...


  • User Attivo

    ...non funziona

    <?
    function ddt($id){
    $obj=new sast1com();
    $obj->connessione();
    $dati=mysql_query("select * from ddd where id='$id'");
    while($array=mysql_fetch_array($dati)){
    return "$array[progressivo]<br>$array[dataemissione]";
    }
    }
    echo ddt($idcliente);
    ?>


  • User Attivo

    @peterminnow said:

    è proprio quello il problema se cambio il campo from in ddt ed il resto progressivo ecc. non sunziona...

    Ciao, io voglio aiutarti, ma ti avevo chiesto di postarmi la tabella interessata
    Ciao:?


  • User Attivo

    CREATE TABLE IF NOT EXISTS ddt (
    id int(11) NOT NULL auto_increment,
    progressivo int(11) NOT NULL,
    idcliente int(11) NOT NULL default '0',
    dataemissione varchar(30) NOT NULL default '',
    anno int(11) NOT NULL default '0',
    causale varchar(50) NOT NULL,
    trasporto varchar(50) NOT NULL,
    colli varchar(30) NOT NULL,
    datatrasporto varchar(50) NOT NULL,
    oratrasporto varchar(50) NOT NULL,
    vettore varchar(40) NOT NULL,
    testonoteddt longtext NOT NULL,
    luogodestinazione longtext NOT NULL,
    PRIMARY KEY (id)
    ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=57 ;

    --
    -- Dump dei dati per la tabella ddt

    INSERT INTO ddt (id, progressivo, idcliente, dataemissione, anno, causale, trasporto, colli, datatrasporto, oratrasporto, vettore, testonoteddt, luogodestinazione) VALUES
    (56, 8, 35, '29/11/2011', 0, '31', 'Mittente', 'A vista', '29/11/2011', '15:36', '', 'testonoteddt', ''),
    (55, 7, 34, '29/11/2011', 0, '31', '', 'A vista', '29/11/2011', '13:40', '', 'testonoteddt', ''),
    (54, 6, 34, '29/11/2011', 0, '32', 'Mittente', 'A vista', '29/11/2011', '13:40', '', 'testonoteddt', '');