query semplice?

Trapano

Utente Attivo
27 Set 2012
238
0
16
48
Eccomi a casa...ho copiato, incollato e scrutato...
Nulla di buono...
Trova i record che cerco ma il tasto "invio" non fa nulla...
Queste le due pagine...
ddt.php
PHP:
<?php 
session_start();//sempre meglio metterla prima 
include 'conf.php'; 
if ($_SESSION['username']==$usern); 
else{  
    header("Location: login.htm"); 
    exit();//metti l'exit per essere sicuro che durante il caricamento non possa essere letta 
} 
$oggi=date('yW'); 
//a che ti serve aprire e chiudere in fondo la {} 
?> 
<html> 
<head> 
<title>DDT</title> 
</head> 
<body><!-- e il  <body>...</body>--> 
<!-- table e tr ?? --> 
<font size='2'><!-- tag font deprecato usa i css --> 
<form align='' action='ddt.php?reg=1' method='POST'> 
<table><tr><td align='left'> 
Inserisci l'indice <input type='text' name='txt' value='<?php echo $oggi; ?>'> 
<input style='color:black; background-color: #999999;' type='submit' name ='cerca' value='Cerca'> 
</td></tr></table> 
</form> 
</font> 
<?php 

if(isset($_POST['cerca'])){ 
    $DB_host     = 'localhost';
$DB_user     = 'XXXXXX';
$DB_password = 'XXXXX';
$DB_name     = 'XXXX'; 
    $b=date('ymd'); 
    $bi=date('d/m/y'); 
    $link = mysql_connect($DB_host, $DB_user, $DB_password); 
    if (!$link) { 
        die ('Non riesco a connettermi: ' . mysql_error()); 
    } 
    $db_selected = mysql_select_db($DB_name, $link); 
    if (!$db_selected) { 
        die ("Errore nella selezione del database: " . mysql_error()); 
    } 
    $txt = $_POST['txt'];//nessuna verifica ?? 
    echo "<td align='left'><p align='left'><font color='black' size='4'> 
        <b>Elenco DDT $bi</b><a title='STAMPA' href='javascript:print();'> 
        <input style='color:black;background-color:;' type='submit' value='Stampa'></a></font></p><td>"; 
        //non ti cinverrebbe al posto dell'input mettere un'immaginetta? ([B]L'immaginetta, quando me la meriterò...![/B])
    $result = mysql_query("SELECT * FROM fatture WHERE doc LIKE 'DDT' && indice = '$txt' order by id desc"); 
    $num=mysql_num_rows($result);//forse intendevi $num=mysql_num_rows($result) Questo non serve a nulla??? Lo tolgo?!
    //poi questo ti converrebbe trasmetterlo alla pag invio.php per verificare che tutti i campi siano stati compilate 
    //il numero dei post pieni deve essere uguale a questo numero 
    //lo puoi tramettere con un campo hidden  [B](Qui per me è ARABO!)[/B]
    //e poi a che ti serve dovresti mettere un if 
    /* 
    if($num > 0){ 
        //tutto l'ambaradan del form [B](Qui devo inserire i <td> del form?)[/B]
    }else{ 
        echo "non ci sono risultati, modifica dati di ricerca"; 
    } 
    */ 
    echo "<form method='POST' name='modulo' action='invio.php'  target='_blank'>"; 
    echo "<input name=\"numero\" type=\"hidden\" value=\"$num\">"; 
    echo "<table style='border: 1px solid white' align='left' bgcolor='' border='1' width='100%' cellpadding='0' cellspacing='0'>"; 
    echo "<tr>  
        <th align='center' width=''><font size='2'>Ragione sociale</th> 
        <th align='center' width=''><font size='2'>Documento</th> 
        <th align='center' width=''><font size='2'>Numero</th> 
        <th align='center' width=''><font size='2'>Emissione</th> 
        <th align='center' width=''><font size='2'>Codice cliente</th> 
        <th align='center' width=''><font size='2'>Importo DDT</th> 
        <th align='center' width=''><font size='2'>Data</th> 
        <th align='center' width=''><font size='2'>Tipo</th> 
        </tr>";  
    $totale_importo = 0; 
    while($row = mysql_fetch_array( $result )) {  
        $id=$row['id'];  
        echo "<tr>  
             <td align='center'><font size='2'><input type='text' name='nome[]' maxlength='30' value='".$row['nome']."'></font></td>  
             <td align='center'><font size='2'><input type='text' name='doc[]' maxlength='30' value='".$row['doc']."'></font></td>  
             <td align='center'><font size='2'><input type='text' name='numero[]' maxlength='30' value='".$row['numero']."'></font></td>  
             <td align='center'><font size='2'><input type='text' name='emissione[]' maxlength='30' value='".$row['emissione']."'></font></td>  
             <td align='center'><font size='2'><input type='text' name='codcliente[]' maxlength='30' value='".$row['codcliente']."'></font></td>  
             <td align='center'><font size='2'><input type='text' name='importoDDT[]' maxlength='30' value='".$row['importoDDT']."'></font></td>  
             <td align='center'><font size='2'><input type='text' name='data[]' maxlength='30' value='".$row['data']."'></font></td>  
             <td align='center'><font size='2'><input type='text' name='tipo[]' maxlength='30' value='".$row['tipo']."'></font></td>  
            </tr>"; 
         $totale_importo += $row['importoDDT'];   
         
    }   
    echo "<td> <input type='button' value='Invia' onClick='Modulo()'></td>"; // onClick serve ancora?
    echo "</table><br>"; 
    echo "</form>"; 
?> 
<table style='border: 1px solid white' align='left' bgcolor='' border='0' width='100%' cellpadding='0' cellspacing='10'> 
<td align="center"><font size='2'>Totale importo: <b><?php echo $totale_importo; ?>&nbsp;</b>euro</font></td> 
</table> 
<?php 
}//fine if dell'isset 
?> 
</body> 
</html>

la pagina Invio.php
PHP:
<?php 
//varie info per email
$oggi = date("j F Y G:i");
$sito = "XXX";
$mittente = "[email protected]";
$ip = "$_SERVER[REMOTE_ADDR]";
$browser = "$_SERVER[HTTP_USER_AGENT]";
$to = "[email protected]";
$soggetto = "DDT da Fatturare";


//..... 
$errore=""; 
for($j=0; $j < count($_POST['nome']; $j++){ 
    if(trim($_POST['nome'][$j]) ==""){$errore.="il campo nome ".($j+1)." obbligatorio<br>";} 
    if(trim($_POST['doc'][$j]) ==""){$errore.="il campo documento ".($j+1)." obbligatorio<br>";}
    if(trim($_POST['numero'][$j]) ==""){$errore.="il campo numero ".($j+1)." obbligatorio<br>";}
    if(trim($_POST['emissione'][$j]) ==""){$errore.="il campo emesso il ".($j+1)." obbligatorio<br>";}
    if(trim($_POST['codcliente'][$j]) ==""){$errore.="il campo codcliente ".($j+1)." obbligatorio<br>";}
    if(trim($_POST['importoDDT'][$j]) ==""){$errore.="il campo importoDDT ".($j+1)." obbligatorio<br>";}
    if(trim($_POST['data'][$j]) ==""){$errore.="il campo data ".($j+1)." obbligatorio<br>";}
    if(trim($_POST['tipo'][$j]) ==""){$errore.="il campo tipo ".($j+1)." obbligatorio<br>";} 
    //ecc... per tutti i campi 
} 
if($errore==""){ 
    $totale=0; 
    $messaggio= "<table>"; 
    $messaggio .= "<tr>  
            <th align='center' width=''><font size='2'>Ragione sociale</th> 
            <th align='center' width=''><font size='2'>Documento</th> 
            <th align='center' width=''><font size='2'>Numero</th> 
            <th align='center' width=''><font size='2'>Emissione</th> 
            <th align='center' width=''><font size='2'>Codice cliente</th> 
            <th align='center' width=''><font size='2'>Importo DDT</th> 
            <th align='center' width=''><font size='2'>Data</th> 
            <th align='center' width=''><font size='2'>Tipo</th> 
            </tr>"; 
    for($j=0; $j < count($_POST['nome']; $j++){ 
        $messaggio .= "<tr>"; 
        $messaggio .= "<td>".$_POST['nome'][$j]."</td><td>".$_POST['doc'][$j]."</td><td>".$_POST['numero'][$j]."</td><td>".$_POST['emissione'][$j]."</td><td>".$_POST['codcliente'][$j]."</td><td>".$_POST['importoDDT'][$j]."</td><td>".$_POST['data'][$j]."</td><td>".$_POST['tipo'][$j]."</td>"; 
        $totale +=$_POST['importoDDT'][$j] 
    } 
    $messaggio .= "</tr>"; 
    $messaggio .= "<tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr>";//il numero dei <td>..</td> deve essere come ha impostato la tabella o usare colspan 
    $messaggio .="</table>"; 
    //e qui lo stampi o fai quello che vuoi 
    echo $messaggio; 
}else{ 
    echo $errore; 
    //e riinvii dove vuoi 
} 
//... 
?>

<html>
<head>
<title>Annuncio inviato</title>
</head>
<body background="white" style="background-attachment: fixed; text-align:center" link="black" vlink="black" alink="black" text="black">
<div align="center"><BR><br>
<font size="+1" face=""><strong>Il modulo è stato inviato con successo!<br><br> Grazie.
</strong></font><br><br>
<td align='left'><font size='2'><a title='CHIUDI PAGINA' target='_self' href='Javascript:self. close();'>
<input style='color:black;background-color:#33FF33;' type='submit' value="Chiudi pagina"></a></font></td>
</div>
</body>
</html>
<?php
}
?>


Un macello!
 

borgo italia

Super Moderatore
Membro dello Staff
SUPER MOD
MOD
4 Feb 2008
16.046
150
63
PR
www.borgo-italia.it
ciao l'onclik mi sono dimenticato di toglerlo, poi al posto del button metti

PHP:
echo "<td> <input type='submit' value='Invia' nane='invia'></td>";
 
Discussioni simili
Autore Titolo Forum Risposte Data
S semplice query che non funziona :( PHP 3
A [MYSQL+PHP]Non riesco a fare la query!!!Penso sia semplice.. PHP 1
max75 query su due tabelle e dati doppioni MS Access 2
E Aiuto per query PHP 8
E Query differenza tra tabelle MySQL 5
E Query Alias PHP 4
T Query con date MS Access 1
K Inserimento query Errore 1366 PHP 4
L Query e selezione DB con $_POST PHP 2
M query update e delete PHP 0
A media degli elementi estratti da una query MySQL 0
S Passare query o utm alla pagina successiva Domini 1
O problema con query PHP 4
M Query PHP 8
R query DELETE non cancella i record PHP 1
G Query con i giorni della settimana MySQL 10
E Query annidate o cicli MySQL 1
C bottone query MySQL 0
T Query su due tabelle con totali Database 4
G AVVISO QUERY IN ESECUZIONE PHP 1
M Riportare in tabella HTML dati estratti con query SQL MySQL 0
S Selezionare ultimo record di una sotto query MySQL 27
G Menù a tendina di ricerca con query PHP 1
V Query per una somma PHP 2
F stampare a video i risultati della query PHP 1
L problema con query select PHP 2
D Query sum Database 1
M Visualizzazione a video risultati query php PHP 0
A form PHP prenotazione tramite query PHP 2
R Problema query con ricerca id numerico PHP 2
G Casella combinata in una query MS Access 4
R Aiuto con le query MS Access 2
Y query di DELETE PHP 4
V Query Oracle Oracle 0
L query somma PHP 8
W Query SQL Classic ASP 2
M Problemi con query a più tabelle PHP 3
Alex_70 Conteggio nella query PHP 0
elpirata Query per leggere dati da una tabella mysql e mostrarli a video in base a parametri passati tramite GET PHP 5
A nome file che contiene punto passato come parametro a query PHP 31
F query e form con select multipla PHP 17
M Problema su query JOIN in tre tabelle PHP 0
M Ordinare una query join PHP 2
Alex_70 Query ORDER BY PHP 18
G Problema ------- con Query PHP 1
G Problema con Query PHP 1
Alex_70 foreach explode query PHP 3
O query con date in formato stringa PHP 3
Tommy03 Unione query di 4 tabelle MySQL 1
I Fatal error: Query Failed! SQL: SELECT * INTO OUTFILE PHP 1

Discussioni simili