- Home
- Categorie
- Coding e Sistemistica
- Coding
- Estrazione dati MYSQL
- 
							
							
							
							
							non ci sono errori in questo modo...ma come stampo i risultati? 
 
- 
							
							
							
							
							
@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
 
- 
							
							
							
							
							<? 
 $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]; ?> 
 
- 
							
							
							
							
							
@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 
 
- 
							
							
							
							
							non stampa nulla...ma senza errori 
 
- 
							
							
							
							
							
@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
 
- 
							
							
							
							
							...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);
 ?>
 
- 
							
							
							
							
							
@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  
 Ciao, ma molto strano dovrebbe funzionare anche l'altra, comunque è semplice modifica i camppi nella query e la lanci
 
- 
							
							
							
							
							è proprio quello il problema se cambio il campo from in ddt ed il resto progressivo ecc. non sunziona... 
 
- 
							
							
							
							
							...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);
 ?>
 
- 
							
							
							
							
							
@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:?
 
- 
							
							
							
							
							CREATE TABLE IF NOT EXISTS ddt(
 idint(11) NOT NULL auto_increment,
 progressivoint(11) NOT NULL,
 idclienteint(11) NOT NULL default '0',
 dataemissionevarchar(30) NOT NULL default '',
 annoint(11) NOT NULL default '0',
 causalevarchar(50) NOT NULL,
 trasportovarchar(50) NOT NULL,
 collivarchar(30) NOT NULL,
 datatrasportovarchar(50) NOT NULL,
 oratrasportovarchar(50) NOT NULL,
 vettorevarchar(40) NOT NULL,
 testonoteddtlongtext NOT NULL,
 luogodestinazionelongtext NOT NULL,
 PRIMARY KEY (id)
 ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=57 ;--
 -- Dump dei dati per la tabelladdtINSERT 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', '');
 
- 
							
							
							
							
							
Ciao, ho provato anche con il while e problemi non me ne da, solo che ho dovuto togliere tutto l'ambarabà sopra, uso poco le function anche se dovrei cominciare prima o poi 
 [PHP]
 $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'];
 [/PHP][PHP] 
 $dati=mysql_query("select * from ddt where id='2'");
 while($array=mysql_fetch_array($dati))
 {
 echo $array['progressivo'];
 }
 [/PHP]
 mo arrivato a questo punto non saprei proprio che dirti.
 Parola a chi ne sa di più
 Ciao 
 
- 
							
							
							
							
							provo ancora con quanto mi hai detto fino ad ora!