Greetings.
I need the following:
Select records from a database and show them grouped by
1. Date
2. Manager
3. Status
So, I've developed the following code:
$sth = $dbh->prepare_cached("SELECT DISTINCT A.p_code, A.busin
+ess, A.status, A.value, A.login, A.enc_date,
B.name, B.state
FROM business A, users B
WHERE ORDER BY A.login, A.data_enc_proposta");
}
$dbh = SysUtils::Connect;
$sth->execute;
while (@data = $sth->fetchrow_array())
{
$rs = $data[0];
$neg = $data[1];
$st = $data[2];
$vp = $data[3];
$gel = $data[4];
$dte = $data[5];
$gen = $data[6];
$fil = $data[7];
%dados = ($fil => {$gel => {"$dte" => { cliente => "$rs",
nego
+cio => "$neg",
stat
+us => "$st",
valo
+r => "$vp",
nome
+ => "$gen"
}
}
}
);
ListaDados();
and here is the sub that shows them:
foreach (keys (%dados))
{
$vf = "R\$ ";
$tf = "R\$ ";
$dados{$fil}{$gel}{$dte}{valor} =~ s/\.0000$/\,00/;
$vf .= $dados{$fil}{$gel}{$dte}{valor};
if ($cnt eq 0)
{
$message .= "<TR class=\"texto3\">
<TD colspan=\"4\" BGCOLOR=\"$color2\"><span class =\"texto
+2\">$dados{$fil}{$gel}{$dte}{nome}</span></TD>
</TR>
<TABLE WIDTH=\"100%\" BORDER=\"0\" CELLSPACING=\"0\" CELLP
+ADDING=\"0\">
<TR CLASS=\"texto2\">
<TD>Client</TD>
<TD>Business</TD>
<TD>Status</TD>
<TD>Value</TD>
</TR>
<TR>
<TD COLSPAN=\"4\">
<HR>
</TD>
</TR>
<TR CLASS=\"texto3\">
<TD BGCOLOR=\"$color2\">$dados{$fil}{$gel}{$dte}{cliente}<
+/TD>
<TD BGCOLOR=\"$color2\">$dados{$fil}{$gel}{$dte}{negocio}<
+/TD>
<TD BGCOLOR=\"$color2\">$dados{$fil}{$gel}{$dte}{status}</
+TD>
<TD BGCOLOR=\"$color2\">$vf</TD>
</TR>";
$cnt++;
($color2,$color1) = ($color1,$color2);
}
else
{
$message .= "<TR CLASS=\"texto3\">
<TD BGCOLOR=\"$color2\">$dados{$fil}{$gel}{$dte}{cliente}<
+/TD>
<TD BGCOLOR=\"$color2\">$dados{$fil}{$gel}{$dte}{negocio}<
+/TD>
<TD BGCOLOR=\"$color2\">$dados{$fil}{$gel}{$dte}{status}</
+TD>
<TD BGCOLOR=\"$color2\">$vf</TD>
</TR>";
($color2,$color1) = ($color1,$color2);
}
}
}
Well, it's generating multiple results and it returns the wrong manager (the alphabetically first on the users table), so something is going real wrong here...
Could you guys please give me a hand here?
Thanks in advance,
Er Galvão Abbott
a.k.a. Lobo, DaWolf
Webdeveloper