473,385 Members | 2,243 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Need help with table display

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
1 1860

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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Umesh | last post by:
Hi I am developing a windows application. This contains a Data grid which will populate data from a data table in a Dataset. The application will do some calculation and store the result in the...
3
by: google | last post by:
I have a database with four table. In one of the tables, I use about five lookup fields to get populate their dropdown list. I have read that lookup fields are really bad and may cause problems...
9
by: Susan Bricker | last post by:
Greetings. I am having trouble populating text data that represents data in my table. Here's the setup: There is a People Table (name, address, phone, ...) peopleID = autonumber key There...
5
by: JackM | last post by:
I need a little guidance putting a script together. I'm trying to read a list of image links from a text file (not a database) and display them in a table on my page. I want to display them in rows...
2
by: Severus Snape | last post by:
I can display and hide 1 object at a time, but haven't seen it done on multiple objects simultaneously. I have four (or more) tables on a page that start off hidden, and I want to toggle their...
9
by: wparrott | last post by:
I have a table called tblPayScales. It has 5 fields: numRecID - record ID txtCLASSCODE - a 1 or 2 letter text value (A, B, C, BD, L, LT, etc.) numPAYSTEP - a number value 0-49 numSALARY - a...
2
by: sorobor | last post by:
dear sir .. i am using cakephp freamwork ..By the way i m begener in php and javascript .. My probs r bellow I made a javascript calender ..there is a close button ..when i press close button...
13
by: Effix | last post by:
Hi everybody I have yet another problem, actually two but lets start with this one :-) Im making a very simple gallery or at least I think its simple. I have already made a upload script that...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.