[nycphp-talk] more queries, or bigger in-memory data structure ?
Analysis & Solutions
danielc at analysisandsolutions.com
Thu Sep 18 17:29:43 EDT 2003
David:
On Thu, Sep 18, 2003 at 05:03:20PM -0400, David Mintz wrote:
>
> I believe I do follow you and I don't think it would do for me (or, it
> would work, and I do not understand you (-:).
Seems to be the latter. :)
> Judge Language Defendant Interpreter
> ------------------------------------
> Jones Spanish Estrada Mirta
> Jones Spanish Estrada Elena
>
> ...then I want to display
>
> Judge Language Defendant Interpreters
> ---------------------------------------
> Jones Spanish Estrada Mirta, Elena
>
> ...because that's what makes sense to the user. Zat make any sense?
Yes. That's exactly what I thought you were talking about.
So, psuedo code...
$LastEvent = 0;
$LastDefendant = '';
$LastInterpreter = '';
$Defendants = array();
$Interpreters = array();
while ($row = fetchrow()) {
if ($row['eventid'] != $LastEvent) {
$LastJudge = $row['judge'];
if ($row['Defendant'] != $LastDefendant) {
$LastDefendant = $row['Defendant'];
$Defednants[] = $row['Defendant'];
}
if ($row['Interpreter'] != $LastInterpreter) {
$LastInterpreter = $row['Interpreter'];
$Interpreters[] = $row['Interpreter'];
}
} else {
echo "<tr><td>$LastJudge</td>";
echo '<td>' . implode(', ', $Defendants) . '</td>';
echo '<td>' . implode(', ', $Interpreters) . "</td></tr>\n";
$Defendants = array();
$Interpreters = array();
$Defednants[] = $row['Defendant'];
$Interpreters[] = $row['Interpreter'];
// also probably need to set the $Last* vars too,
// but I'm getting lazy and you get the idea by now...
}
}
--
FREE scripts that make web and database programming easier
http://www.analysisandsolutions.com/software/
T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y
4015 7th Ave #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409
More information about the talk
mailing list