Ciao a tutti,
scusate per il titolo ma non sapevo cosa mettere.
Il mio problema è questo.
Ho creato uno script che funziona perfettamente, il casino mi vien fuori nel momento della formattazione nel browser.
$query = " SELECT id,num_spedizione,cod_eser,insegna,via,num_civico, localita,provincia,cap FROM mat01 WHERE data = '20051121'";
$ris = mysql_query($query,$conn) or die("Errore nella query:" . mysql_error());
echo "<table border=\"1\" bordercolor=\"#000000\" cellspacing=\"0\" cellpadding=\"5\"><div class=\"pagina\"><tr class=\"testa\"><td>Id</td><td>7000000000</td><td>7000000005</td></tr>";
while($riga = mysql_fetch_array($ris)) {
echo "<tr class=\"anagr\"><td>".$riga["id"]."</td>";
$query2 = "SELECT * FROM mat02 WHERE num_spedizione = '".$riga["num_spedizione"]."' AND mat02.cod_mat = '7000000000'";
$ris2 = mysql_query($query2,$conn) or die("Errore nella query: " . mysql_error());
while($riga2 = mysql_fetch_array($ris2))
{
if ($riga2 > '0') {
echo "<td align=\"center\">".$riga2["quantita_spedita"]."</td>";
} else {
echo "<td></td>";
}}
$query3 = "SELECT * FROM mat02 WHERE num_spedizione = '".$riga["num_spedizione"]."' AND mat02.cod_mat = '7000000005'";
$ris3 = mysql_query($query3,$conn) or die("Errore nella query: " . mysql_error());
while($riga3 = mysql_fetch_array($ris3))
{
if ($riga3 > '0') {
echo "<td align=\"center\">".$riga3["quantita_spedita"]."</td>";
} else {
echo "<td></td>";
}}
}
$rs = mysql_query("SELECT SUM(quantita_spedita) AS totale2 FROM mat01,mat02 WHERE mat01.num_spedizione = mat02.num_spedizione AND mat01.data = '20051121' AND mat02.cod_mat = '7000000000'");
$row = mysql_fetch_array($rs);
$rs1 = mysql_query("SELECT SUM(quantita_spedita) AS totale3 FROM mat01,mat02 WHERE mat01.num_spedizione = mat02.num_spedizione AND mat01.data = '20051121' AND mat02.cod_mat = '7000000005'");
$row1 = mysql_fetch_array($rs1);
echo "<tr><td>Totale</td><td>".$row['totale2']."</td><td>".$row1['totale3']."</td></tr>";
e questa è una porzione del risultato
Id 7000000000 7000000005
5966 5 1
5967 2 1
5968
5969
5970 4 1
5971 3 1
5972 2 1
5973 4 1
5974 4 1
5975
5976
5977
5978 1 1
5979 4 1
5980 1 1
5981 1
Il record incriminato è quest'ultimo il 5981, dove il risultato dovrebbe essere nella seconda colonna, invece me lo mette nella prima.
Pensavo di risolvere il dramma mettendo degli if nei cicli di while
$query2 = "SELECT * FROM mat02 WHERE num_spedizione = '".$riga["num_spedizione"]."' AND mat02.cod_mat = '7000000000'";
$ris2 = mysql_query($query2,$conn) or die("Errore nella query: " . mysql_error());
while($riga2 = mysql_fetch_array($ris2))
{
if ($riga2 > '0') {
echo "<td align=\"center\">".$riga2["quantita_spedita"]."</td>";
} else {
echo "<td></td>";
}}
$query3 = "SELECT * FROM mat02 WHERE num_spedizione = '".$riga["num_spedizione"]."' AND mat02.cod_mat = '7000000005'";
$ris3 = mysql_query($query3,$conn) or die("Errore nella query: " . mysql_error());
while($riga3 = mysql_fetch_array($ris3))
{
if ($riga3 > '0') {
echo "<td align=\"center\">".$riga3["quantita_spedita"]."</td>";
} else {
echo "<td></td>";
}}
Ovverosia, quando trova $riga2 magg di 0 lui mi stampa la cella col valore, altrimenti DOVREBBE stamparmi una cella vuota...INVECE nisba...
secondo voi, dove sta l'arcano?
Grazie in anticipo a chi potrà aiutarmi