Solved

help with php loop, irr, database mysql

Posted on 2008-10-12
3
187 Views
Last Modified: 2013-12-12
I have this script working for the most part so far, but there must be an error in a loop or code that is adding the Final Period Payout in the second and third Final Period Payouts

and I believe that the same error is affecting the display block.

please see www.bayparkcapital.com/G.php

thanks for the help.

<?php
//connect to server
$mysqli = mysqli_connect("");
$username = $_SESSION['loggedin'];
//gather the topics
$get_topics_sql = "SELECT topic_id, topic_title, DATE_FORMAT(topic_create_time,  '%b %e %Y at %r') aS fmt_topic_create_time, topic_owner, INV_ID,INV_U_N, MS_F_NAME, MS_ID, CONT_DIST_1_1_08, cf_1_1_00, cf_2_1_00, cf_3_1_00,      cf_4_1_00,      cf_5_1_00,      cf_6_1_00,      cf_7_1_00,      cf_8_1_00,      cf_9_1_00,      cf_10_1_00,      cf_11_1_00,      cf_12_1_00,      cf_1_1_01,      cf_2_1_01,      cf_3_1_01,      cf_4_1_01,      cf_5_1_01,      cf_6_1_01,      cf_7_1_01,      cf_8_1_01,      cf_9_1_01,      cf_10_1_01,      cf_11_1_01,      cf_12_1_01,      cf_1_1_02,      cf_2_1_02,      cf_3_1_02,      cf_4_1_02,      cf_5_1_02,      cf_6_1_02,      cf_7_1_02,      cf_8_1_02,      cf_9_1_02,      cf_10_1_02,      cf_11_1_02,      cf_12_1_02,      cf_1_1_03,      cf_2_1_03,      cf_3_1_03,      cf_4_1_03,      cf_5_1_03,      cf_6_1_03,      cf_7_1_03,      cf_8_1_03,      cf_9_1_03,      cf_10_1_03,      cf_11_1_03,      cf_12_1_03,      cf_1_1_04,      cf_2_1_04,      cf_3_1_04,      cf_4_1_04,      cf_5_1_04,      cf_6_1_04,      cf_7_1_04,      cf_8_1_04,      cf_9_1_04,      cf_10_1_04,      cf_11_1_04,      cf_12_1_04,      cf_1_1_05,      cf_2_1_05,      cf_3_1_05,      cf_4_1_05,      cf_5_1_05,      cf_6_1_05,      cf_7_1_05,      cf_8_1_05,      cf_9_1_05,      cf_10_1_05,      cf_11_1_05,      cf_12_1_05,      cf_1_1_06,      cf_2_1_06,      cf_3_1_06,      cf_4_1_06,      cf_5_1_06,      cf_6_1_06,      cf_7_1_06,      cf_8_1_06,      cf_9_1_06,      cf_10_1_06,      cf_11_1_06,      cf_12_1_06,      cf_1_1_07,      cf_2_1_07,      cf_3_1_07,      cf_4_1_07,      cf_5_1_07,      cf_6_1_07,      cf_7_1_07,      cf_8_1_07,      cf_9_1_07,      cf_10_1_07,      cf_11_1_07,      cf_12_1_07,      cf_1_1_08,      cf_2_1_08,      cf_3_1_08,      cf_4_1_08,      cf_5_1_08,      cf_6_1_08,      cf_7_1_08,      cf_8_1_08,      cf_9_1_08,      cf_10_1_08,      cf_11_1_08,      cf_12_1_08 FROM invdb ORDER BY topic_create_time DESC";
$get_topics_res = mysqli_query($mysqli, $get_topics_sql) or die(mysqli_error($mysqli));

if (mysqli_num_rows($get_topics_res) < 1) {

      //there are no topics, so say so
      $display_block = "<p><em>No topics exist.</em></p>";
} else {
 
      //create the display string
      $display_block
             ?>
      <table cellpadding="4" cellspacing="1" border="1" border-color="black" style="font-size:10px" >
      <tr>
            <th>Cash&nbsp;Flow&nbsp;Month_Year</th>
            <th>12_08</th>
            <th>11_08</th>
            <th>10_08</th>
            <th>9_08</th>
            <th>8_08</th>
            <th>7_08</th>
            <th>6_08</th>
            <th>5_08</th>
            <th>4_08</th>
            <th>3_08</th>
            <th>2_08</th>
            <th>1_08</th>
            <th>12_07</th>
            <th>11_07</th>
            <th>10_07</th>
            <th>9_07</th>
            <th>8_07</th>
            <th>7_07</th>
            <th>6_07</th>
            <th>5_07</th>
            <th>4_07</th>
            <th>3_07</th>
            <th>2_07</th>
            <th>1_07</th>
            <th>12_06</th>
            <th>11_06</th>
            <th>10_06</th>
            <th>9_06</th>
            <th>8_06</th>
            <th>7_06</th>
            <th>6_06</th>
            <th>5_06</th>
            <th>4_06</th>
            <th>3_06</th>
            <th>2_06</th>
            <th>1_06</th>
            <th>12_05</th>
            <th>11_05</th>
            <th>10_05</th>
            <th>9_05</th>
            <th>8_05</th>
            <th>7_05</th>
            <th>6_05</th>
            <th>5_05</th>
            <th>4_05</th>
            <th>3_05</th>
            <th>2_05</th>
            <th>1_05</th>
            <th>12_04</th>
            <th>11_04</th>
            <th>10_04</th>
            <th>9_04</th>
            <th>8_04</th>
            <th>7_04</th>
            <th>6_04</th>
            <th>5_04</th>
            <th>4_04</th>
            <th>3_04</th>
            <th>2_04</th>
            <th>1_04</th>
            <th>12_03</th>
            <th>11_03</th>
            <th>10_03</th>
            <th>9_03</th>
            <th>8_03</th>
            <th>7_03</th>
            <th>6_03</th>
            <th>5_03</th>
            <th>4_03</th>
            <th>3_03</th>
            <th>2_03</th>
            <th>1_03</th>
            <th>12_02</th>
            <th>11_02</th>
            <th>10_02</th>
            <th>9_02</th>
            <th>8_02</th>
            <th>7_02</th>
            <th>6_02</th>
            <th>5_02</th>
            <th>4_02</th>
            <th>3_02</th>
            <th>2_02</th>
            <th>1_02</th>
            <th>12_01</th>
            <th>11_01</th>
            <th>10_01</th>
            <th>9_01</th>
            <th>8_01</th>
            <th>7_01</th>
            <th>6_01</th>
            <th>5_01</th>
            <th>4_01</th>
            <th>3_01</th>
            <th>2_01</th>
            <th>1_01</th>
            <th>12_00</th>
            <th>11_00</th>
            <th>10_00</th>
            <th>9_00</th>
            <th>8_00</th>
            <th>7_00</th>
            <th>6_00</th>
            <th>5_00</th>
            <th>4_00</th>
            <th>3_00</th>
            <th>2_00</th>
            <th>1_00</th>
      </tr>
    <?php

      while ($topic_info = mysqli_fetch_array($get_topics_res)) {
      
            $p = array('cf_12_1_08','cf_11_1_08','cf_10_1_08','cf_9_1_08');
            $topic_id = $topic_info['topic_id'];
            $topic_title = stripslashes($topic_info['topic_title']);
            $topic_create_time = $topic_info['fmt_topic_create_time'];
            $topic_owner = stripslashes($topic_info['topic_owner']);
        $filename = stripslashes($topic_info['filename']);
            $topic_id = $topic_info['topic_id'];
            $topic_title = stripslashes($topic_info['topic_title']);
            $topic_create_time = $topic_info['fmt_topic_create_time'];
            $topic_owner = stripslashes($topic_info['topic_owner']);
        $filename = stripslashes($topic_info['filename']);
            $INV_ID = stripslashes($topic_info['INV_ID']);
            $INV_U_N = stripslashes($topic_info['INV_U_N']);
            $MS_F_NAME = stripslashes($topic_info['MS_F_NAME']);
            $MS_ID = stripslashes($topic_info['MS_ID']);
            $CHECK = stripslashes($topic_info['CHECK']);
            $INV_ID = stripslashes($topic_info['INV_ID']);
            $MS_INV_ID = stripslashes($topic_info['MS_INV_ID']);
            $CONT_DIST_1_1_08 = stripslashes($topic_info['CONT_DIST_1_1_08']);
            $payoff = 10000;
            $cf_12_1_08 = stripslashes($topic_info['cf_12_1_08']);
            $cf_11_1_08 = stripslashes($topic_info['cf_11_1_08']);
            $cf_10_1_08 = stripslashes($topic_info['cf_10_1_08']);
            $cf_9_1_08 = stripslashes($topic_info['cf_9_1_08']);
            $cf_8_1_08 = stripslashes($topic_info['cf_8_1_08']);
            $cf_7_1_08 = stripslashes($topic_info['cf_7_1_08']);
            $cf_6_1_08 = stripslashes($topic_info['cf_6_1_08']);
            $cf_5_1_08 = stripslashes($topic_info['cf_5_1_08']);
            $cf_4_1_08 = stripslashes($topic_info['cf_4_1_08']);
            $cf_3_1_08 = stripslashes($topic_info['cf_3_1_08']);
            $cf_2_1_08 = stripslashes($topic_info['cf_2_1_08']);
            $cf_1_1_08 = stripslashes($topic_info['cf_1_1_08']);
            $cf_12_1_07 = stripslashes($topic_info['cf_12_1_07']);
            $cf_11_1_07 = stripslashes($topic_info['cf_11_1_07']);
            $cf_10_1_07 = stripslashes($topic_info['cf_10_1_07']);
            $cf_9_1_07 = stripslashes($topic_info['cf_9_1_07']);
            $cf_8_1_07 = stripslashes($topic_info['cf_8_1_07']);
            $cf_7_1_07 = stripslashes($topic_info['cf_7_1_07']);
            $cf_6_1_07 = stripslashes($topic_info['cf_6_1_07']);
            $cf_5_1_07 = stripslashes($topic_info['cf_5_1_07']);
            $cf_4_1_07 = stripslashes($topic_info['cf_4_1_07']);
            $cf_3_1_07 = stripslashes($topic_info['cf_3_1_07']);
            $cf_2_1_07 = stripslashes($topic_info['cf_2_1_07']);
            $cf_1_1_07 = stripslashes($topic_info['cf_1_1_07']);
            $cf_12_1_06 = stripslashes($topic_info['cf_12_1_06']);
            $cf_11_1_06 = stripslashes($topic_info['cf_11_1_06']);
            $cf_10_1_06 = stripslashes($topic_info['cf_10_1_06']);
            $cf_9_1_06 = stripslashes($topic_info['cf_9_1_06']);
            $cf_8_1_06 = stripslashes($topic_info['cf_8_1_06']);
            $cf_7_1_06 = stripslashes($topic_info['cf_7_1_06']);
            $cf_6_1_06 = stripslashes($topic_info['cf_6_1_06']);
            $cf_5_1_06 = stripslashes($topic_info['cf_5_1_06']);
            $cf_4_1_06 = stripslashes($topic_info['cf_4_1_06']);
            $cf_3_1_06 = stripslashes($topic_info['cf_3_1_06']);
            $cf_2_1_06 = stripslashes($topic_info['cf_2_1_06']);
            $cf_1_1_06 = stripslashes($topic_info['cf_1_1_06']);
            $cf_12_1_05 = stripslashes($topic_info['cf_12_1_05']);
            $cf_11_1_05 = stripslashes($topic_info['cf_11_1_05']);
            $cf_10_1_05 = stripslashes($topic_info['cf_10_1_05']);
            $cf_9_1_05 = stripslashes($topic_info['cf_9_1_05']);
            $cf_8_1_05 = stripslashes($topic_info['cf_8_1_05']);
            $cf_7_1_05 = stripslashes($topic_info['cf_7_1_05']);
            $cf_6_1_05 = stripslashes($topic_info['cf_6_1_05']);
            $cf_5_1_05 = stripslashes($topic_info['cf_5_1_05']);
            $cf_4_1_05 = stripslashes($topic_info['cf_4_1_05']);
            $cf_3_1_05 = stripslashes($topic_info['cf_3_1_05']);
            $cf_2_1_05 = stripslashes($topic_info['cf_2_1_05']);
            $cf_1_1_05 = stripslashes($topic_info['cf_1_1_05']);
            $cf_12_1_04 = stripslashes($topic_info['cf_12_1_04']);
            $cf_11_1_04 = stripslashes($topic_info['cf_11_1_04']);
            $cf_10_1_04 = stripslashes($topic_info['cf_10_1_04']);
            $cf_9_1_04 = stripslashes($topic_info['cf_9_1_04']);
            $cf_8_1_04 = stripslashes($topic_info['cf_8_1_04']);
            $cf_7_1_04 = stripslashes($topic_info['cf_7_1_04']);
            $cf_6_1_04 = stripslashes($topic_info['cf_6_1_04']);
            $cf_5_1_04 = stripslashes($topic_info['cf_5_1_04']);
            $cf_4_1_04 = stripslashes($topic_info['cf_4_1_04']);
            $cf_3_1_04 = stripslashes($topic_info['cf_3_1_04']);
            $cf_2_1_04 = stripslashes($topic_info['cf_2_1_04']);
            $cf_1_1_04 = stripslashes($topic_info['cf_1_1_04']);
            $cf_12_1_03 = stripslashes($topic_info['cf_12_1_03']);
            $cf_11_1_03 = stripslashes($topic_info['cf_11_1_03']);
            $cf_10_1_03 = stripslashes($topic_info['cf_10_1_03']);
            $cf_9_1_03 = stripslashes($topic_info['cf_9_1_03']);
            $cf_8_1_03 = stripslashes($topic_info['cf_8_1_03']);
            $cf_7_1_03 = stripslashes($topic_info['cf_7_1_03']);
            $cf_6_1_03 = stripslashes($topic_info['cf_6_1_03']);
            $cf_5_1_03 = stripslashes($topic_info['cf_5_1_03']);
            $cf_4_1_03 = stripslashes($topic_info['cf_4_1_03']);
            $cf_3_1_03 = stripslashes($topic_info['cf_3_1_03']);
            $cf_2_1_03 = stripslashes($topic_info['cf_2_1_03']);
            $cf_1_1_03 = stripslashes($topic_info['cf_1_1_03']);
            $cf_12_1_02 = stripslashes($topic_info['cf_12_1_02']);
            $cf_11_1_02 = stripslashes($topic_info['cf_11_1_02']);
            $cf_10_1_02 = stripslashes($topic_info['cf_10_1_02']);
            $cf_9_1_02 = stripslashes($topic_info['cf_9_1_02']);
            $cf_8_1_02 = stripslashes($topic_info['cf_8_1_02']);
            $cf_7_1_02 = stripslashes($topic_info['cf_7_1_02']);
            $cf_6_1_02 = stripslashes($topic_info['cf_6_1_02']);
            $cf_5_1_02 = stripslashes($topic_info['cf_5_1_02']);
            $cf_4_1_02 = stripslashes($topic_info['cf_4_1_02']);
            $cf_3_1_02 = stripslashes($topic_info['cf_3_1_02']);
            $cf_2_1_02 = stripslashes($topic_info['cf_2_1_02']);
            $cf_1_1_02 = stripslashes($topic_info['cf_1_1_02']);
            $cf_12_1_01 = stripslashes($topic_info['cf_12_1_01']);
            $cf_11_1_01 = stripslashes($topic_info['cf_11_1_01']);
            $cf_10_1_01 = stripslashes($topic_info['cf_10_1_01']);
            $cf_9_1_01 = stripslashes($topic_info['cf_9_1_01']);
            $cf_8_1_01 = stripslashes($topic_info['cf_8_1_01']);
            $cf_7_1_01 = stripslashes($topic_info['cf_7_1_01']);
            $cf_6_1_01 = stripslashes($topic_info['cf_6_1_01']);
            $cf_5_1_01 = stripslashes($topic_info['cf_5_1_01']);
            $cf_4_1_01 = stripslashes($topic_info['cf_4_1_01']);
            $cf_3_1_01 = stripslashes($topic_info['cf_3_1_01']);
            $cf_2_1_01 = stripslashes($topic_info['cf_2_1_01']);
            $cf_1_1_01 = stripslashes($topic_info['cf_1_1_01']);
            $cf_12_1_00 = stripslashes($topic_info['cf_12_1_00']);
            $cf_11_1_00 = stripslashes($topic_info['cf_11_1_00']);
            $cf_10_1_00 = stripslashes($topic_info['cf_10_1_00']);
            $cf_9_1_00 = stripslashes($topic_info['cf_9_1_00']);
            $cf_8_1_00 = stripslashes($topic_info['cf_8_1_00']);
            $cf_7_1_00 = stripslashes($topic_info['cf_7_1_00']);
            $cf_6_1_00 = stripslashes($topic_info['cf_6_1_00']);
            $cf_5_1_00 = stripslashes($topic_info['cf_5_1_00']);
            $cf_4_1_00 = stripslashes($topic_info['cf_4_1_00']);
            $cf_3_1_00 = stripslashes($topic_info['cf_3_1_00']);
            $cf_2_1_00 = stripslashes($topic_info['cf_2_1_00']);
            $cf_1_1_00 = stripslashes($topic_info['cf_1_1_00']);
                                          
            $seq = array( $cf_12_1_08,
$cf_11_1_08,
$cf_10_1_08,
$cf_9_1_08,
$cf_8_1_08,
$cf_7_1_08,
$cf_6_1_08,
$cf_5_1_08,
$cf_4_1_08,
$cf_3_1_08,
$cf_2_1_08,
$cf_1_1_08,
$cf_12_1_07,
$cf_11_1_07,
$cf_10_1_07,
$cf_9_1_07,
$cf_8_1_07,
$cf_7_1_07,
$cf_6_1_07,
$cf_5_1_07,
$cf_4_1_07,
$cf_3_1_07,
$cf_2_1_07,
$cf_1_1_07,
$cf_12_1_06,
$cf_11_1_06,
$cf_10_1_06,
$cf_9_1_06,
$cf_8_1_06,
$cf_7_1_06,
$cf_6_1_06,
$cf_5_1_06,
$cf_4_1_06,
$cf_3_1_06,
$cf_2_1_06,
$cf_1_1_06,
$cf_12_1_05,
$cf_11_1_05,
$cf_10_1_05,
$cf_9_1_05,
$cf_8_1_05,
$cf_7_1_05,
$cf_6_1_05,
$cf_5_1_05,
$cf_4_1_05,
$cf_3_1_05,
$cf_2_1_05,
$cf_1_1_05,
$cf_12_1_04,
$cf_11_1_04,
$cf_10_1_04,
$cf_9_1_04,
$cf_8_1_04,
$cf_7_1_04,
$cf_6_1_04,
$cf_5_1_04,
$cf_4_1_04,
$cf_3_1_04,
$cf_2_1_04,
$cf_1_1_04,
$cf_12_1_03,
$cf_11_1_03,
$cf_10_1_03,
$cf_9_1_03,
$cf_8_1_03,
$cf_7_1_03,
$cf_6_1_03,
$cf_5_1_03,
$cf_4_1_03,
$cf_3_1_03,
$cf_2_1_03,
$cf_1_1_03,
$cf_12_1_02,
$cf_11_1_02,
$cf_10_1_02,
$cf_9_1_02,
$cf_8_1_02,
$cf_7_1_02,
$cf_6_1_02,
$cf_5_1_02,
$cf_4_1_02,
$cf_3_1_02,
$cf_2_1_02,
$cf_1_1_02,
$cf_12_1_01,
$cf_11_1_01,
$cf_10_1_01,
$cf_9_1_01,
$cf_8_1_01,
$cf_7_1_01,
$cf_6_1_01,
$cf_5_1_01,
$cf_4_1_01,
$cf_3_1_01,
$cf_2_1_01,
$cf_1_1_01,
$cf_12_1_00,
$cf_11_1_00,
$cf_10_1_00,
$cf_9_1_00,
$cf_8_1_00,
$cf_7_1_00,
$cf_6_1_00,
$cf_5_1_00,
$cf_4_1_00,
$cf_3_1_00,
$cf_2_1_00,
$cf_1_1_00,
);
            //add to display
            $display_block .= "
                              
            <tr>
            <td>".$topic_create_time."</td>
            <th>".$final_period."</th>      
            <th>".$cf_11_1_08."</th>
            <th>".$cf_10_1_08."</th>
            <th>".$cf_9_1_08."</th>
            <th>".$cf_8_1_08."</th>
            <th>".$cf_7_1_08."</th>
            <th>".$cf_6_1_08."</th>
            <th>".$cf_5_1_08."</th>
            <th>".$cf_4_1_08."</th>
            <th>".$cf_3_1_08."</th>
            <th>".$cf_2_1_08."</th>
            <th>".$cf_1_1_08."</th>
            <th>".$cf_12_1_07."</th>
            <th>".$cf_11_1_07."</th>
            <th>".$cf_10_1_07."</th>
            <th>".$cf_9_1_07."</th>
            <th>".$cf_8_1_07."</th>
            <th>".$cf_7_1_07."</th>
            <th>".$cf_6_1_07."</th>
            <th>".$cf_5_1_07."</th>
            <th>".$cf_4_1_07."</th>
            <th>".$cf_3_1_07."</th>
            <th>".$cf_2_1_07."</th>
            <th>".$cf_1_1_07."</th>
            <th>".$cf_12_1_06."</th>
            <th>".$cf_11_1_06."</th>
            <th>".$cf_10_1_06."</th>
            <th>".$cf_9_1_06."</th>
            <th>".$cf_8_1_06."</th>
            <th>".$cf_7_1_06."</th>
            <th>".$cf_6_1_06."</th>
            <th>".$cf_5_1_06."</th>
            <th>".$cf_4_1_06."</th>
            <th>".$cf_3_1_06."</th>
            <th>".$cf_2_1_06."</th>
            <th>".$cf_1_1_06."</th>
            <th>".$cf_12_1_05."</th>
            <th>".$cf_11_1_05."</th>
            <th>".$cf_10_1_05."</th>
            <th>".$cf_9_1_05."</th>
            <th>".$cf_8_1_05."</th>
            <th>".$cf_7_1_05."</th>
            <th>".$cf_6_1_05."</th>
            <th>".$cf_5_1_05."</th>
            <th>".$cf_4_1_05."</th>
            <th>".$cf_3_1_05."</th>
            <th>".$cf_2_1_05."</th>
            <th>".$cf_1_1_05."</th>
            <th>".$cf_12_1_04."</th>
            <th>".$cf_11_1_04."</th>
            <th>".$cf_10_1_04."</th>
            <th>".$cf_9_1_04."</th>
            <th>".$cf_8_1_04."</th>
            <th>".$cf_7_1_04."</th>
            <th>".$cf_6_1_04."</th>
            <th>".$cf_5_1_04."</th>
            <th>".$cf_4_1_04."</th>
            <th>".$cf_3_1_04."</th>
            <th>".$cf_2_1_04."</th>
            <th>".$cf_1_1_04."</th>
            <th>".$cf_12_1_03."</th>
            <th>".$cf_11_1_03."</th>
            <th>".$cf_10_1_03."</th>
            <th>".$cf_9_1_03."</th>
            <th>".$cf_8_1_03."</th>
            <th>".$cf_7_1_03."</th>
            <th>".$cf_6_1_03."</th>
            <th>".$cf_5_1_03."</th>
            <th>".$cf_4_1_03."</th>
            <th>".$cf_3_1_03."</th>
            <th>".$cf_2_1_03."</th>
            <th>".$cf_1_1_03."</th>
            <th>".$cf_12_1_02."</th>
            <th>".$cf_11_1_02."</th>
            <th>".$cf_10_1_02."</th>
            <th>".$cf_9_1_02."</th>
            <th>".$cf_8_1_02."</th>
            <th>".$cf_7_1_02."</th>
            <th>".$cf_6_1_02."</th>
            <th>".$cf_5_1_02."</th>
            <th>".$cf_4_1_02."</th>
            <th>".$cf_3_1_02."</th>
            <th>".$cf_2_1_02."</th>
            <th>".$cf_1_1_02."</th>
            <th>".$cf_12_1_01."</th>
            <th>".$cf_11_1_01."</th>
            <th>".$cf_10_1_01."</th>
            <th>".$cf_9_1_01."</th>
            <th>".$cf_8_1_01."</th>
            <th>".$cf_7_1_01."</th>
            <th>".$cf_6_1_01."</th>
            <th>".$cf_5_1_01."</th>
            <th>".$cf_4_1_01."</th>
            <th>".$cf_3_1_01."</th>
            <th>".$cf_2_1_01."</th>
            <th>".$cf_1_1_01."</th>
            <th>".$cf_12_1_00."</th>
            <th>".$cf_11_1_00."</th>
            <th>".$cf_10_1_00."</th>
            <th>".$cf_9_1_00."</th>
            <th>".$cf_8_1_00."</th>
            <th>".$cf_7_1_00."</th>
            <th>".$cf_6_1_00."</th>
            <th>".$cf_5_1_00."</th>
            <th>".$cf_4_1_00."</th>
            <th>".$cf_3_1_00."</th>
            <th>".$cf_2_1_00."</th>
            <th>".$cf_1_1_00."</th>
            </tr>
            ";
      // foreach($seq as $key => $value) {  print ":$key =&gt; $value <br/>"; }
      $cashflow = array( $cf_12_1_08,
$cf_11_1_08,
$cf_10_1_08,
$cf_9_1_08,
$cf_8_1_08,
$cf_7_1_08,
$cf_6_1_08,
$cf_5_1_08,
$cf_4_1_08,
$cf_3_1_08,
$cf_2_1_08,
$cf_1_1_08,
$cf_12_1_07,
$cf_11_1_07,
$cf_10_1_07,
$cf_9_1_07,
$cf_8_1_07,
$cf_7_1_07,
$cf_6_1_07,
$cf_5_1_07,
$cf_4_1_07,
$cf_3_1_07,
$cf_2_1_07,
$cf_1_1_07,
$cf_12_1_06,
$cf_11_1_06,
$cf_10_1_06,
$cf_9_1_06,
$cf_8_1_06,
$cf_7_1_06,
$cf_6_1_06,
$cf_5_1_06,
$cf_4_1_06,
$cf_3_1_06,
$cf_2_1_06,
$cf_1_1_06,
$cf_12_1_05,
$cf_11_1_05,
$cf_10_1_05,
$cf_9_1_05,
$cf_8_1_05,
$cf_7_1_05,
$cf_6_1_05,
$cf_5_1_05,
$cf_4_1_05,
$cf_3_1_05,
$cf_2_1_05,
$cf_1_1_05,
$cf_12_1_04,
$cf_11_1_04,
$cf_10_1_04,
$cf_9_1_04,
$cf_8_1_04,
$cf_7_1_04,
$cf_6_1_04,
$cf_5_1_04,
$cf_4_1_04,
$cf_3_1_04,
$cf_2_1_04,
$cf_1_1_04,
$cf_12_1_03,
$cf_11_1_03,
$cf_10_1_03,
$cf_9_1_03,
$cf_8_1_03,
$cf_7_1_03,
$cf_6_1_03,
$cf_5_1_03,
$cf_4_1_03,
$cf_3_1_03,
$cf_2_1_03,
$cf_1_1_03,
$cf_12_1_02,
$cf_11_1_02,
$cf_10_1_02,
$cf_9_1_02,
$cf_8_1_02,
$cf_7_1_02,
$cf_6_1_02,
$cf_5_1_02,
$cf_4_1_02,
$cf_3_1_02,
$cf_2_1_02,
$cf_1_1_02,
$cf_12_1_01,
$cf_11_1_01,
$cf_10_1_01,
$cf_9_1_01,
$cf_8_1_01,
$cf_7_1_01,
$cf_6_1_01,
$cf_5_1_01,
$cf_4_1_01,
$cf_3_1_01,
$cf_2_1_01,
$cf_1_1_01,
$cf_12_1_00,
$cf_11_1_00,
$cf_10_1_00,
$cf_9_1_00,
$cf_8_1_00,
$cf_7_1_00,
$cf_6_1_00,
$cf_5_1_00,
$cf_4_1_00,
$cf_3_1_00,
$cf_2_1_00,
$cf_1_1_00,
);
{
$period_to_solve = 12;
$rate = 0.15;

//First sum all of the period there is info for!
for ($x=0; $x<$period_to_solve; $x++)
{
$sum += $cashflow[$x] / pow($rate + 1, $x);
}
// NPV = {sum} + x/(1+rate)^4
//  -{sum} * (1+rate)^4 = x
$final_period = 0 - $sum * pow(1+$rate,$period_to_solve);
?><p><strong>Discounted Cash Flow Sum Through 11-08</strong>:&nbsp;<?
 echo $sum;
  }
 ?>

 </p>
<p><strong>Final Period Payout</strong>:&nbsp;
<?php echo $final_period;?>
</p>
<? print_r($cashflow) ;
      
      }
         //free results
      mysqli_free_result($get_topics_res);
      //close connection to mysqli
      mysqli_close($mysqli);
      //close up the table
      $display_block .= "</table>";
      }
?>

<html>
<head>
<meta http-equiv="content-Type" content="text/html; charset=iso-8859-1" /><meta name="keywords" content="Members Page">
<meta name="Description" content="Members Page">
<title>Member Page</title>
<link rel="stylesheet" type="text/css" media="screen" href="/images/style_032508.css" />
<link rel="stylesheet" type="text/css" media="screen" href="/images/style_0325081.css" />
<link rel="stylesheet" type="text/css" media="screen" href="style_032508.css" />
<link rel="stylesheet" type="text/css" media="screen" href="style_0325081.css" />
</head>
<div id="nav_top"><a href="/">Home</a> | <a href="/about">About Us</a> | <a href="/contact">Contact</a> | <a href="/site map">Site Map</a>| <a href="/login">Log Out</a></div>
<div id="bkg" style="width:auto;">
<div id="body" style="font-size:10px; ">
<p><span class="heading" style="width:600px; padding-top:20px;">View Your Internal Rate of Return</span></p>
<?php echo $display_block; ?></th>
 <?php //foreach($seq as $key => $value) {  print ":$key =&gt; $value <br/>"; } ?>

</div>
</div>
</body>
</html>
0
Comment
Question by:derekstattin
  • 2
3 Comments
 

Author Comment

by:derekstattin
ID: 22700356
The adding is also occuring with the $sum
thanks again
0
 
LVL 17

Accepted Solution

by:
HuyBD earned 500 total points
ID: 22701100
add to line
            <th>".$cf_1_1_00."</th>
            </tr>
            ";
       ?????
       }
      $cashflow = array( $cf_12_1_08.......
........
            <th>".$cf_1_1_00."</th>
            </tr>
            ";
       $data="";
       foreach($seq as $key => $value) {  
            if(!key)//$key is zero, first element
               $data.=sprintf('<td>%1$d</td>',array_sum($seq));
            else
               $data.=sprintf('<td>%1$d</td>',$value);
       }
      $cashflow = array( $cf_12_1_08,......

Open in new window

0
 
LVL 17

Expert Comment

by:HuyBD
ID: 22701110
then try add
.......
<table>
<?php echo $display_block; ?>
<tr>
<?php echo $data; ?>
</tr>
</table>
......

Open in new window

0

Featured Post

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Dynamic Dropdowns 15 33
Link failure 16 35
issue with DB import 1 20
script logging me in even though database user activation value isn't equal to "yes" 5 29
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question