By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,746 Members | 1,735 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,746 IT Pros & Developers. It's quick & easy.

Need help with table display

P: n/a
Hi,

Newbie here. After a few days of sleep depravation i gave up and
decides to ask for help, so anything you can do for me will be much
apreciated, what i´´m trying to do is organize the results in a table
and then add the xolumns by credit terms:

table looks like this:

CLIENTE/FACTURA/TERMINO/ADEUDO
000001 /1111111/30 DIAS / 1500
000002 /1111112/30 DIAS / 3000
000002 /1111113/60 DIAS/ 2000
000001 /1111114/90 DIAS / 2500
000002 /1111115/60 DIAS / 1000

and the desired display would look like:

CLIENTE 000002

FACTURA/30 dias /60dias/90 dias/ No especificado/ TOTAL
1111112/1500 / ____ /______/ ____________/ 1500
1111113/______/2000 / _____/ ____________ / 2000
1111115/______ /1000 /_____ /_____________ / 1000

TOTAL 1500 / 3000 /_____/ ____________ / 4500

So far what i have is the next code:

echo "<table>";
$resultado=mysql_query("select * from cliente_facturas where
cliente=$cliente order by cliente,factura");
$t30=0; // total 30 días
$t60=0; // total 60 días
$t90=0; // total 90 días
$tind=0; // total no especificado
while ($filas=mysql_fetch_array($resultado))
{
echo "<tr><td>$filas['factura']</td>";
switch ($termino) {
case '30 DIAS':
$t30+=$filas["adeudo"];
echo "<td>$filas['adeudo']</td><td> </td><td> </td><td>
</td>";
break;
case '60 DIAS':
$t60+=$filas["adeudo"];
echo "<td> </td><td>$filas['adeudo']</td><td> </td><td>
</td>";
break;
case '90 DIAS':
$t90+=$filas["adeudo"];
echo "<td> </td><td> </td><td>$filas['adeudo']</td><td>
</td>";
break;
default:
$tind+=$filas["adeudo"];
echo "<td> </td><td> </td><td>
</td><td>$filas['adeudo']</td>";
break;
}
echo "</tr>";
}
echo "<tr><td>TOTAL:</td><td>$t30</td><td>$t60</td><td>$t90</td><td>$tind</td><td>$t30+$t60+$t90+$tind</td></tr></table>";

Thanks!!
Jul 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a

On 25-Oct-2003, ov****@hotmail.com (Ovidal) wrote:
Newbie here. After a few days of sleep depravation i gave up and
decides to ask for help, so anything you can do for me will be much
apreciated, what i´´m trying to do is organize the results in a table
and then add the xolumns by credit terms:

table looks like this:

CLIENTE/FACTURA/TERMINO/ADEUDO
000001 /1111111/30 DIAS / 1500
000002 /1111112/30 DIAS / 3000
000002 /1111113/60 DIAS/ 2000
000001 /1111114/90 DIAS / 2500
000002 /1111115/60 DIAS / 1000

and the desired display would look like:

CLIENTE 000002

FACTURA/30 dias /60dias/90 dias/ No especificado/ TOTAL
1111112/1500 / ____ /______/ ____________/ 1500
1111113/______/2000 / _____/ ____________ / 2000
1111115/______ /1000 /_____ /_____________ / 1000

TOTAL 1500 / 3000 /_____/ ____________ / 4500


try this:
echo "<table>";
$resultado=mysql_query("select * from cliente_facturas where
cliente=$cliente order by cliente,factura");
$t30=0; // total 30 días
$t60=0; // total 60 días
$t90=0; // total 90 días
$tind=0; // total no especificado
$last_factura=false; //
echo "<tr><th>FACTURA</th>";
echo "<th>30 dias</th>";
echo "<th>60 dias</th>";
echo "<th>90 dias</th>";
echo "<th>No especificado</th>";
echo "<th>TOTAL</th>";
echo "</tr>";
while ($filas=mysql_fetch_array($resultado))
{
if ($last_factura != $filas['factura'])
{
if ($last_factura !== false)
{
echo "<tr><td>$filas['factura']</td>";
echo "<td>$val_30</td>";
echo "<td>$val_60</td>";
echo "<td>$val_90</td>";
echo "<td>$val_ind</td>";
echo "<td>$val_sum</td>";
echo "</tr>";
$t30 += $val_30;
$t60 += $val_60;
$t90 += $val_90;
$tind += $val_ind;
$total += $val_sum;
}
$val_30 = 0;
$val_60 = 0;
$val_90 = 0;
$val_ind = 0;
$val_sum = 0;
$last_factura = $filas['factura'];
}
$val_sum+=$filas["adeudo"];
switch ($termino) {
case '30 DIAS':
$val_30+=$filas["adeudo"];
break;
case '60 DIAS':
$val_60+=$filas["adeudo"];
break;
case '90 DIAS':
$val_90+=$filas["adeudo"];
break;
default:
$val_ind+=$filas["adeudo"];
break;
}
}
if ($last_factura !== false)
{
echo "<tr><td>$filas['factura']</td>";
echo "<td>$val_30</td>";
echo "<td>$val_60</td>";
echo "<td>$val_90</td>";
echo "<td>$val_ind</td>";
echo "<td>$val_sum</td>";
echo "</tr>";
$t30 += $val_30;
$t60 += $val_60;
$t90 += $val_90;
$tind += $val_ind;
$total += $val_sum;
}
echo
"<tr><td>TOTAL:</td><td>$t30</td><td>$t60</td><td>$t90</td><td>$tind</td><td>$total</td></tr></table>";
--
Tom Thackrey
www.creative-light.com
tom (at) creative (dash) light (dot) com
do NOT send email to ja*********@willglen.net (it's reserved for spammers)
Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.