473,387 Members | 1,495 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,387 software developers and data experts.

Changing a Field in a Database Table

I need to calculate a capital and put the information inside of a table, but something doesn't work well, can you help me.what i try to do is to calculate when final capital will be equal to the initial one and secondly the intereste slow down eatch year. so with out any table i have no problem , but i can not make work the table, i don't know what i need to do.
Expand|Select|Wrap|Line Numbers
  1. <html><head><title>calcul du capital</title></head>
  2. <body bgcolor="#ffcc99">
  3. <h1>Calcul du capital</h1>
  4. <?php
  5. $capital_initial=100;
  6. $taux_initial=2.5;
  7. $capital_final=1000;
  8. $annees=2007;
  9.  
  10. print "<h2>Tableau de l'évolution du capital</h2><BR>";
  11.  
  12. $capital=$capital_initial;
  13. $taux=$taux_initial;
  14.  echo "<TABLE BORDER='1'>";
  15.   echo "<tr><td>annees</td><td>taux d'interet</td><td>capital</td></tr>";
  16.  
  17. while ($capital<$capital_final)
  18. {
  19.  
  20. echo"<TR>";
  21. $capital=$capital*(1+$taux/100);
  22. echo"<TR>"
  23. for($i=0,$i<???,$i++){
  24. echo "<tr><td>".$row["annees"]."</td><td>".$row["taux"]."</td><td>".$row["capital"]."</td></tr>;
  25.    }
  26. $annees=$annees+1
  27. $taux=$taux-.1    
  28.  
  29.    echo "</TABLE>";
  30.  }
  31. ?>
  32.  
thanks
Jun 15 '07 #1
2 1158
The code below will create table output for you. With your orignal code you would never see the output because the criteria to complete the "while" statement is never met. The interest rate became negative before capital exceeded capital_final, which then caused the value of capital to decrease.

So I made a few changes in your formula just to show you the table results.

Expand|Select|Wrap|Line Numbers
  1. <body bgcolor="#ffcc99">
  2. <h1>Calcul du capital</h1>
  3. <h2>Tableau de l'évolution du capital</h2>
  4. <TABLE BORDER='1'>
  5. <tr>
  6.     <th>annees</th>
  7.     <th>taux d'interet</th>
  8.     <th>capital</th>
  9. </tr>
  10.  
  11. <?php 
  12.     $capital_initial=100;
  13.     $taux_initial=2.5;
  14.     $capital_final=120;
  15.     $annees=2007;
  16.     $capital=$capital_initial;
  17.     $taux=$taux_initial;
  18.     echo "capital = " . $capital . "<br />taux = " . $taux . "<br />capital_final = " . $capital_final;
  19.  
  20.     while ($capital < $capital_final) {
  21. ?>
  22.         <tr>
  23.             <td>
  24.                 <?php echo $annees; ?>
  25.             </td>
  26.             <td>
  27.                 <?php echo $taux; ?>
  28.             </td>
  29.             <td>
  30.                 <?php echo $capital; ?>
  31.             </td>
  32.         </tr>
  33. <?php
  34.     $capital=$capital*(1+($taux/100));
  35.     $annees=$annees+1;
  36.     $taux=$taux-.1;
  37.     }
  38. ?>
  39. </TABLE>
  40. </body>
  41.  
Jun 15 '07 #2
pbmods
5,821 Expert 4TB
Heya, Stephan. Welcome to TSDN!

What is your code doing? What is it supposed to be doing?

P.S., Changed thread title. We know it's a PHP problem; that's why you posted it in the PHP forum :)
Jun 17 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

13
by: Peter | last post by:
Can anyone tell me how to change the data type of a field in a table created with a make table query? The field is a binary and must be changed to text. alternately does anyone know how to specify...
16
by: StenKoll | last post by:
Help needed in order to create a register of stocks in a company. In accordance with local laws I need to give each individual share a number. I have accomplished this by establishing three tables...
0
by: me here | last post by:
I have a VBA subroutine that links an MS Excel spreadsheet and copies the data into a local table. This process is controlled by a form that allows users to select the spreadsheet from the file...
3
by: Michael | last post by:
Hi everyone, I am trying to change the field names for a table that is being exported via Excel. Its a spreadsheet that our National Office sends us but even after promise after promise they...
3
by: sparks | last post by:
I was copying fields from one table to another. IF the var name starts with milk I change it to egg and create it in the destination table. It works fine but I want to copy the description as...
10
by: Marizel | last post by:
I'm not sure there's an easy solution to this, but thought I'd ask. I often find myself with a query which I'd like to reuse, but with a different datasource. These datasources generally have...
6
by: David Gartrell | last post by:
Hi i'm trying to import an Excel Spreadsheet into Access2000 but the data types for two of the fields in my imported table are being identified incorrectly. Is there a way of using some VB code in...
32
by: deko | last post by:
I have a popup form with a textbox that is bound to a memo field. I've been warned about memo fields so I'm wondering if I should use this code. Is there any risk with changing the form's...
1
by: mplus_2000 | last post by:
I have recently inherited a database. The switchboard (and other forms) displays the name of the database on it (top, center). Currently the name that appears is Reviews. There are plans to roll...
3
by: sbaird | last post by:
Aloha from Hawaii, I'm beating my head on the wall here. I have a recruiting contact managment database I'm trying to create. Managers (there ar 14 of them) have to make a certain number of...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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.