Solved

Code Breaks in Between Stuck and need help Desperatly

Posted on 2008-10-30
8
248 Views
Last Modified: 2013-12-13
hi
I am attaching the code as well as the File
the code breaks in line 80 itself and then doesnt execute any while loop i dont know why is this happening
please help me i am in deep trouble if this thing doesnt work
<?php
 

include("connect.php");

$mo1 = $_POST['select1'];

$dy1 = $_POST['select2'];

$yr1 = $_POST['select3'];

$mo2 = $_POST['select4'];

$dy2 = $_POST['select5'];

$yr2 = $_POST['select6'];
 

                      $qdel = "truncate table temp; DBCC CHECKIDENT('temp', reseed, 0)";

                      $rdel = mssql_query($qdel);

                      $qdel2 = "delete from src";

                      $rdel2 = mssql_query($qdel2);

                      $qdel3 = "delete from bofa";

                      $rdel3 = mssql_query($qdel3);

                      $qdel4 = "delete from income";

                      $rdel4 = mssql_query($qdel4);

                      $qdel5 = "delete from expense";

                      $rdel5 = mssql_query($qdel5);

//echo "<br>populate Income,Expense and Bofa Table";

                      $qpieb1 = "insert bofa(acc_no) select distinct(b.account_no) from bofa_table_1 b where (b.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2')";

                      $rpieb1 = mssql_query($qpieb1);

                      $qpieb2 = "insert income(account_no) select right(t5.trailer_1,8) from Table_5 t5 where ((t5.account_no like '4W7F%') and (t5.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

                      $rpieb2 = mssql_query($qpieb2);

                      $qpieb3 = "insert expense(account_no) select right(t5.trailer_1,8) from Table_5 t5 where ((t5.account_no like '4W7G%') and (t5.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

                      $rpieb3 = mssql_query($qpieb3);

//echo "<br>Update Income,Expense and Bofa Table";

                      $quieb1 = "update bofa set acc_no=substring(acc_no,1,4) from bofa where (acc_no like '4%' or acc_no like '7%')";

                      $ruieb1 = mssql_query($quieb1);

                      $quieb2 = "update income set account_no=substring(account_no,1,4) from income where (account_no like '4%' or account_no like '7%')";

                      $ruieb2 = mssql_query($quieb2);

                      $quieb3 = "delete from income where account_no like '74TV'";

                      $ruieb3 = mssql_query($quieb3);

                      $quieb4 = "update expense set account_no=substring(account_no,1,4) from expense where (account_no like '4%' or account_no like '7%')";

                      $ruqib4 = mssql_query($quieb4);

                      $quieb5 = "delete from expense where account_no like '74TV'";

                      $ruieb5 = mssql_query($quieb5);
 

                      $qsel1 = "select account_no from acc where account_no like '5%5'";

                      $rsel1 = mssql_query($qsel1);

                      while($rowsel1 = mssql_fetch_array($rsel1))

  			{

//  			echo "<br>Populate Volume for DVP";

      				$acci = $rowsel1['account_no'];

      				$q_ins1 = "insert temp(v_equity,v_options,v_futures,v_id,acc_no) select sum(abs(cast(t1.trade_quantity as decimal(13,5)))),'0','0','0','$acci' from Table_1 t1,Table_5 t5 where ((t1.account_no like '$acci') and (t1.row_count = t5.row_count) and (t1.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

      				$r_ins1 = mssql_query($q_ins1);

			} 
 

			$qsel2 = "select cl.account_no from acc cl where cl.account_no like '5%5'";

			$rsel2 = mssql_query($qsel2);

			while($rowsel2 = mssql_fetch_array($rsel2))

			{

//			echo "<br>Populate Income columns for DVP";

				$acci = $rowsel2['account_no'];
 

/*

For the time being till we figure it out
 

				    $q_ins2 = "insert temp(i_net_equity,acc_no) select '0','$acci' from Table_1 t1  where (( t1.account_no like '$acci') and (t1.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

			      $r_ins2 = mssql_query($q_ins2);

			      $q_ins3 = "insert temp(i_interest_financing,acc_no) select '0','$acci' from Table_1 t1  where (( t1.account_no like '$acci') and (t1.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

			      $r_ins3 = mssql_query( $q_ins3 );

			      $q_ins4 = "insert temp(i_short_stock_financing,acc_no) select '0','$acci' from Table_1 t1  where (( t1.account_no like '$acci') and (t1.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

			      $r_ins4 = mssql_query( $q_ins4 );
 

*/

			      

			      $q_ins5 = "insert temp(i_total_commissions,acc_no) select sum(abs(t2.local_clearence_charges_1)),'$acci'   from dbo.Table_2 t2,Table_5 t5  where (( t2.account_no like '$acci') and ( t2.row_count=t5.row_count )  and (t2.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

			      $r_ins5 = mssql_query( $q_ins5 );

			      $q_ins6 = "insert temp(i_options_clearance,acc_no) select sum(abs(cast(t1.trade_quantity as decimal(13,5)))),'$acci'   from Table_1 t1,Table_5 t5  where ((t1.account_no like '$acci') and (t5.journel_code = 'OPT') and (t1.row_count = t5.row_count ) and (t1.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

			      $r_ins6 = mssql_query( $q_ins6 );

			      $q_ins7 = "insert temp(i_id_tickets,acc_no) select sum(abs(cast(t1.trade_quantity as decimal(13,5)))),'$acci'   from Table_1 t1,Table_5 t5  where ((t1.account_no like '$acci') and (t5.journel_code = 'IDC') and (t1.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

			      $r_ins7 = mssql_query( $q_ins7 );

			      $q_ins8 = "insert temp(i_futures_revenue,i_algo_credit,i_misc,i_soft_dollar,acc_no) select m.software_market_data,'0',m.misc,m.soft_dollar,'$acci' from manual_data m where ((m.account_no like '$acci') and (m.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

			      $r_ins8 = mssql_query( $q_ins8 );

			      $q_ins9 = "insert temp(tmp.i_total_before_soft_dollar,acc_no) select sum(abs(cast(tmp.i_total_commissions as decimal(13, 5))) + abs(cast(tmp.i_options_clearance as decimal(13,5))) + abs(cast(tmp.i_id_tickets as decimal(13,5))) + abs(cast(tmp.i_futures_revenue as decimal(15,5))) + abs(cast(tmp.i_algo_credit as decimal(15,5))) + abs(cast(tmp.i_misc as decimal(15,5)))),'$acci' from temp tmp where (acc_no like '$acci')";

			      $r_ins9 = mssql_query( $q_ins9 );

			} 				
 

			$qsel2 = "select account_no from expense where account_no like '5%5'";

			$rsel2 = mssql_query($qsel2);

			while($rowsel2 = mssql_fetch_array($rsel2))

			{

//			echo "<br>Populate Expense columns for DVP";

			      $acce = $row['account_no'];

			      print_r($rowsel2);

			      echo "$acce";

			      $q_ins9  = "insert temp(e_ticket_charges,acc_no) select sum(abs(cast(t1.trade_quantity as decimal(13,5)))),'$acce' from Table_1 t1,Table_5 t5  where ((t1.account_no like '$acce') and (t1.row_count = t5.row_count ) and (t5.journel_code = 'CLR') and (t1.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

			      $r_ins9  = mssql_query( $q_ins9 );

			      $q_ins10 = "insert temp(e_id_ticket_charges,acc_no) select sum(abs(cast(t1.trade_quantity as decimal(13,5)))),'$acce' from Table_1 t1,Table_5 t5  where ((t1.account_no like  '$acce') and (t5.journel_code = 'IDC') and (t1.row_count = t5.row_count ) and (t1.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

			      $r_ins10 = mssql_query( $q_ins10 );

			      $q_ins11 = "insert temp(e_brokerage_redi,acc_no) select abs(cast(t1.trade_quantity as decimal(13,5)))*(.001),'$acce' from Table_1 t1,Table_5 t5  where (( t1.account_no like '$acce') and (t1.row_count = t5.row_count ) and (t1.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

			      $r_ins11 = mssql_query( $q_ins11 );

			      $q_ins12 = "insert temp(e_brokerage_iq,acc_no) select sum(abs(cast(t1.trade_quantity as decimal(13,5))))*(.0011),'$acce' from Table_1 t1,Table_5 t5  where (( t1.account_no like '$acce') and (t1.row_count = t5.row_count ) and (t1.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

			      $r_ins12 = mssql_query( $q_ins12 );

			      $q_ins13 = "insert temp(e_options,acc_no) select sum(abs(cast(t1.trade_quantity as decimal(13,5)))),'$acce'   from Table_1 t1,Table_5 t5  where (( t1.account_no like '$acce') and (t5.journel_code ='OPT') and (t1.row_count = t5.row_count ) and (t1.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

			      $r_ins13 = mssql_query( $q_ins13 );

			      $q_ins14 = "insert temp(e_options_brokerage,acc_no) select sum(abs(cast(t1.trade_quantity as decimal(13,5)))),'$acce'   from Table_1 t1,Table_5 t5  where (( t1.account_no like '$acce') and (t5.journel_code ='OBR') and (t1.row_count = t5.row_count ) and (t1.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

			      $r_ins14 = mssql_query( $q_ins14 );

			      $q_ins15 = "insert temp(e_futures,acc_no) select '0','$acce'   from Table_1 t1 where (( t1.account_no like '$acce' ) and (t1.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

			      $r_ins15 = mssql_query( $q_ins15 );

			      $q_ins30 = "insert temp(tmp.e_software_mkt_data,tmp.e_misc,acc_no) select avg(m.software_market_data),avg(m.misc),'$acce' from manual_data m where (( m.account_no like '$acce') and (m.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$y2-$yr2'))";

			      $r_ins30 = mssql_query( $q_ins30 );

		              $q_ins31="select sum(abs(cast(tmp.i_total_revenue as decimal(15,5)))) - sum(abs(cast(tmp.e_total_expenses as decimal(15,5)))) from client_table cl, temp tmp where tmp.acc_no like cl.account_no";

		              $r_ins31 = mssql_query( $q_ins31 );

			}
 

			$qsel3="select account_no from acc b where b.account_no like '5%5'";

			echo $qsel3;

			$rsel3 = mssql_query($qsel2);

			while($rowsel3 = mssql_fetch_array($rsel3))

			  {

			  echo "in here";

//			  echo "<br>Populate ECN fees for DVP";

			      $acce=$rowsel3['acc_no'];

			      print_r($rowsel3);

			      $q_ins16 = "insert temp(e_ecn_fees,acc_no) select abs(cast(bofa.exec_share as decimal(13,5)))*(.0026),'$acce' from bofa_table_1 bofa where (( bofa.account_no like '$acce') and (bofa.route like 'ARCA') and (bofa.liquidity like 'R') and (bofa.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

			      $r_ins16 = mssql_query( $q_ins16 );

			      $q_ins17 = "insert temp(e_ecn_fees,acc_no) select abs(cast(bofa.exec_share as decimal(13,5)))*(.0030),'$acce' from bofa_table_1 bofa where (( bofa.account_no like '$acce' ) and (bofa.route like 'ARCA') and (bofa.liquidity like 'X') and (bofa.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

			      $r_ins17 = mssql_query( $q_ins17 );

			      $q_ins18 = "insert temp(e_ecn_fees,acc_no) select abs(cast(bofa.exec_share as decimal(13,5)))*(-.0020),'$acce' from bofa_table_1 bofa where (( bofa.account_no like '$acce') and (bofa.route like 'ARCA') and (bofa.liquidity like 'A') and (bofa.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

			      $r_ins18 = mssql_query( $q_ins18 );

			      $q_ins19 = "insert temp(e_ecn_fees,acc_no) select abs(cast(bofa.exec_share as decimal(13,5)))*(.0030),'$acce' from bofa_table_1 bofa where (( bofa.account_no like '$acce') and (bofa.route like 'ISLD') and (bofa.liquidity like 'R') and (bofa.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

			      $r_ins19 = mssql_query( $q_ins19 );

			      $q_ins20 = "insert temp(e_ecn_fees,acc_no) select abs(cast(bofa.exec_share as decimal(13,5)))*(.0040),'$acce' from bofa_table_1 bofa where (( bofa.account_no like '$acce') and (bofa.route like 'ISLD') and (bofa.liquidity like 'X') and (bofa.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

			      $r_ins20 = mssql_query( $q_ins20 );

			      $q_ins21 = "insert temp(e_ecn_fees,acc_no) select abs(cast(bofa.exec_share as decimal(13,5)))*(-.0020),'$acce' from bofa_table_1 bofa where (( bofa.account_no like '$acce') and (bofa.route like 'ISLD') and (bofa.liquidity like 'A') and (bofa.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

			      $r_ins21 = mssql_query( $q_ins21 );

			      $q_ins22 = "insert temp(e_ecn_fees,acc_no) select abs(cast(bofa.exec_share as decimal(13,5)))*(.0030),'$acce' from bofa_table_1 bofa where (( bofa.account_no like '$acce') and (bofa.route like 'BATS') and (bofa.liquidity like 'R') and (bofa.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

			      $r_ins22 = mssql_query( $q_ins22 );

			      $q_ins23 = "insert temp(e_ecn_fees,acc_no) select abs(cast(bofa.exec_share as decimal(13,5)))*(.0030),'$acce' from bofa_table_1 bofa where (( bofa.account_no like '$acce') and (bofa.route like 'BATS') and (bofa.liquidity like 'X') and (bofa.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

			      $r_ins23 = mssql_query( $q_ins23 );

			      $q_ins24 = "insert temp(e_ecn_fees,acc_no) select abs(cast(bofa.exec_share as decimal(13,5)))*(-.0020),'$acce' from bofa_table_1 bofa where (( bofa.account_no like '$acce') and (bofa.route like 'BATS') and (bofa.liquidity like 'A') and (bofa.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

			      $r_ins24 = mssql_query( $q_ins24 );

			      $q_ins25 = "insert temp(e_ecn_fees,acc_no) select abs(cast(bofa.exec_share as decimal(13,5)))*(.0026),'$acce' from bofa_table_1 bofa where (( bofa.account_no like '$acce') and (bofa.route like 'EDGE') and (bofa.liquidity like 'R') and (bofa.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

			      $r_ins25 = mssql_query( $q_ins25 );

			      $q_ins26 = "insert temp(e_ecn_fees,acc_no) select abs(cast(bofa.exec_share as decimal(13,5)))*(.0029),'$acce' from bofa_table_1 bofa where (( bofa.account_no like '$acce') and (bofa.route like 'EDGE') and (bofa.liquidity like 'X') and (bofa.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

			      $r_ins26 = mssql_query( $q_ins26 );

			      $q_ins27 = "insert temp(e_ecn_fees,acc_no) select abs(cast(bofa.exec_share as decimal(13,5)))*(-.0025),'$acce' from bofa_table_1 bofa where (( bofa.account_no like '$acce') and (bofa.route like 'EDGE') and (bofa.liquidity like 'A') and (bofa.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

			      $r_ins27 = mssql_query( $q_ins27 );

			      $q_ins28 = "insert temp(e_ecn_fees,acc_no) select abs(cast(bofa.exec_share as decimal(13,5)))*(.0026),'$acce' from bofa_table_1 bofa where (( bofa.account_no like '$acce') and (bofa.route like 'NYSE') and (bofa.liquidity like 'R') and (bofa.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

			      $r_ins28 = mssql_query( $q_ins28 );

			      $q_ins29 = "insert temp(e_ecn_fees,acc_no) select abs(cast(bofa.exec_share as decimal(13,5)))*(.0026),'$acce' from bofa_table_1 bofa where (( bofa.account_no like '$acce') and (bofa.route like 'AMEX') and (bofa.liquidity like 'R') and (bofa.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

			      $r_ins29 = mssql_query( $q_ins29 );

			   }

/*$qsel8="select * from acc where account_no like '5%5'";

			$rsel8=mssql_query($qsel8);

			while($rowsel8 = mssql_fetch_array($rsel8))

			  {

			  			  

			  $ac = $rowsel8['account_no'];

			  $fname =$rowsel8['fund_name'];

			  $sales=$rowsel8['rep'];

			  $type=$rowsel8['type'];

			  $query_final="insert into src(acc_no  ,fund_name ,v_equity ,v_options ,v_futures ,v_id ,i_net_equity ,i_interest_financing ,i_short_stock_financing ,i_total_commissions ,i_options_clearance ,i_id_tickets ,i_futures_revenue ,i_algo_credit ,i_misc ,i_total_before_soft_dollar ,i_soft_dollar ,i_total_revenue ,e_ticket_charges ,e_id_ticket_charges ,e_brokerage_redi ,e_brokerage_iq ,e_pipeline ,e_options ,e_options_brokerage ,e_futures ,e_ecn_fees ,e_software_mkt_data ,e_algo_debit ,e_misc ,e_total_expenses ,t_income_from_trading ,t_income_from_financing ,t_total_income ,o_type ,o_sales_rep) select '$ac','$fname' ,sum(abs(cast(t1.v_equity as decimal(13,5)))),sum(abs(cast(t1.v_options as decimal(13,5)))),sum(abs(cast(t1.v_futures as decimal(13,5)))),sum(abs(cast(t1.v_id as decimal(13,5)))),sum(abs(cast(t1.i_net_equity as decimal(13,5)))),sum(abs(cast(t1.i_interest_financing as decimal(13,5)))),sum(abs(cast(t1.i_short_stock_financing as decimal(13,5)))),sum(abs(cast(t1.i_total_commissions as decimal(13,5)))),sum(abs(cast(t1.i_options_clearance as decimal(13,5)))),sum(abs(cast(t1.i_id_tickets as decimal(13,5)))),sum(abs(cast(t1.i_futures_revenue as decimal(13,5)))),sum(abs(cast(t1.i_algo_credit as decimal(13,5)))),sum(abs(cast(t1.i_misc as decimal(13,5)))),sum(abs(cast(t1.i_total_before_soft_dollar as decimal(13,5)))),sum(abs(cast(t1.i_soft_dollar as decimal(13,5)))),sum(abs(cast(t1.i_total_revenue as decimal(13,5)))),sum(abs(cast(t1.e_ticket_charges as decimal(13,5)))),sum(abs(cast(t1.e_id_ticket_charges as decimal(13,5)))),sum(abs(cast(t1.e_brokerage_redi as decimal(13,5)))),sum(abs(cast(t1.e_brokerage_iq as decimal(13,5)))),sum(abs(cast(t1.e_pipeline as decimal(13,5)))),sum(abs(cast(t1.e_options as decimal(13,5)))),sum(abs(cast(t1.e_options_brokerage as decimal(13,5)))),sum(abs(cast(t1.e_futures as decimal(13,5)))),sum(abs(cast(t1.e_ecn_fees as decimal(13,5)))),sum(abs(cast(t1.e_software_mkt_data as decimal(13,5)))),sum(abs(cast(t1.e_algo_debit as decimal(13,5)))),sum(abs(cast(t1.e_misc as decimal(13,5)))),sum(abs(cast(t1.e_total_expenses as decimal(13,5)))),sum(abs(cast(t1.t_income_from_trading as decimal(13,5)))),sum(abs(cast(t1.t_income_from_financing as decimal(13,5)))),sum(abs(cast(t1.t_total_income as decimal(13,5)))),'$type','$sales' from temp t1 where (t1.acc_no='$ac')";

			  $result_final=mssql_query($query_final);

			  }

//        $qdel = "truncate table temp; DBCC CHECKIDENT('temp', reseed, 0)";

//        $rdel = mssql_query($qdel);

*/			

echo "Done for DVP<br>";

			$qsel4 = "select account_no from acc cl where account_no like '4%' or account_no like '7%'";

			$rsel4 = mssql_query($qsel4);

			while($rowsel4 = mssql_fetch_array($rsel4))

			  {

//			  echo "<br>Populating Volumes for Prime Accounts";

			  $acci = $row['account_no'];

			  $q_ins1  = "insert temp(v_equity,acc_no) select sum(abs(cast(t1.trade_quantity as decimal(13,5)))),'$acci' from Table_1 t1,Table_5 t5  where ((t1.account_no = '".$acci."1209')  and (t1.row_count = t5.row_count ) and (t1.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

			  $r_ins1  = mssql_query( $q_ins1 );

			  $q_ins2  = "insert temp(v_options,acc_no) select sum(abs(cast(t1.trade_quantity as decimal(13,5)))),'$acci' from Table_1 t1,Table_5 t5  where ((t1.account_no = '".$acci."0409') and (t1.row_count = t5.row_count )  and (t1.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

			  $r_ins1  = mssql_query( $q_ins1 );

			  $q_ins3  = "insert temp(v_futures,acc_no) select sum(abs(cast(t1.trade_quantity as decimal(13,5)))),'$acci' from Table_1 t1,Table_5 t5  where ((t1.account_no = '".$acci."F909') and (t1.row_count = t5.row_count )  and (t1.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

			  $r_ins3  = mssql_query( $q_ins3 );

			  $q_ins4  = "insert temp(v_id,acc_no) select '0','$acci' from Table_1 t1,Table_5 t5  where ((t1.account_no like '$acci') and (t1.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

			  $r_ins4  = mssql_query( $q_ins4 );

			  }
 

			$qsel5 = "select cl.account_no from income cl where ((cl.account_no like '4%') or (cl.account_no like '7%'))";

			$rsel5 = mssql_query($qsel5);

			while ($rowsel5 = mssql_fetch_array($rsel5))

			  {

//			  echo "<br>Populating Income for Prime Accounts";

			  $acci = $row['account_no'];

			  $q_ins5  = "insert  temp(i_net_equity,acc_no) select '0','$acci' from Table_1 t1  where (( t1.account_no like '$acci%')  and (t1.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

			  $r_ins5  = mssql_query( $q_ins5 );

      			  $q_ins6  = "insert  temp(i_interest_financing,acc_no) select '0','$acci' from Table_1 t1  where (( t1.account_no like '$acci%') and (t1.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

      			  $r_ins6  = mssql_query( $q_ins6 );

      			  $q_ins7  = "insert  temp(i_short_stock_financing,acc_no) select '0','$acci' from Table_1 t1  where (( t1.account_no like '$acci%') and (t1.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

      			  $r_ins7  = mssql_query( $q_ins7 );

      			  $q_ins8  = "insert  temp(i_total_commissions,acc_no) select sum(abs(t2.local_clearence_charges_1)),'$acci' from Table_2 t2,Table_5 t5  where (( t2.account_no like '$acci%') and (t2.row_count = t5.row_count )  and (t2.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

      			  $r_ins8  = mssql_query( $q_ins8 );

      			  $q_ins9  = "insert  temp(i_options_clearance,acc_no) select sum(abs(cast(t1.trade_quantity as decimal(13,5)))),'$acci'   from Table_1 t1,Table_5 t5  where (( t1.account_no like '$acci%') and (t5.journel_code ='OPT') and (t1.row_count = t5.row_count )  and (t1.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

      			  $r_ins9  = mssql_query( $q_ins9 );

      			  $q_ins10 = "insert  temp(i_id_tickets,acc_no) select sum(abs(cast(t1.trade_quantity as decimal(13,5)))),'$acci'   from Table_1 t1,Table_5 t5  where (( t1.account_no like '$acci%') and (t1.row_count = t5.row_count )  and (t5.journel_code ='IDC') and (t1.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

      			  $r_ins10 = mssql_query( $q_ins10 );

      			  $q_ins11 = "insert  temp(i_futures_revenue,i_algo_credit,i_misc,i_soft_dollar,acc_no) select (m.software_market_data),'0',(m.misc),(m.soft_dollar),'$acci' from Table_1 t1,Table_5 t5 ,manual_data m where ((m.account_no = '$acci') and (m.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

      			  $r_ins11 = mssql_query( $q_ins11 );

      			  $q_ins12 = "insert temp(tmp.i_total_before_soft_dollar) select sum(abs(cast(tmp.i_total_commissions as decimal(13, 5))) + abs(cast(tmp.i_options_clearance as decimal(13,5))) + abs(cast(tmp.i_id_tickets as decimal(13,5))) + abs(cast(tmp.i_futures_revenue as decimal(15,5))) + abs(cast(tmp.i_algo_credit as decimal(15,5))) + abs(cast(tmp.i_misc as decimal(15,5)))) from temp tmp where acc_no ='$acci'";

      			  $r_ins12 = mssql_query( $q_ins12 );

			  }
 

			$qsel6="select * from expense where ((account_no like '4%') or (account_no like '7%'))";

			$rsel6=mssql_query($qsel6);

			while($row = mssql_fetch_array($rsel6))

			  {

//			  echo "<br>Populating Expenses for Prime Accounts";

			  $acc = $row['account_no'];

			  $q_ins9 ="insert  temp(e_ticket_charges,acc_no) select sum(abs(cast(t1.trade_quantity as decimal(13,5)))),'$acc'   from Table_1 t1,Table_5 t5  where ( (t1.account_no like '$acc%') and (t5.journel_code ='CLR')  and (t1.row_count = t5.row_count ) and (t1.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

			  $r_ins9  = mssql_query( $q_ins9 );

			  $q_ins10 ="insert  temp(e_id_ticket_charges,acc_no) select sum(abs(cast(t1.trade_quantity as decimal(13,5)))),'$acc'   from Table_1 t1,Table_5 t5  where (( t1.account_no like '$acc%') and (t5.journel_code ='IDC') and (t1.row_count=t5.row_count) and (t1.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

			  $r_ins10 = mssql_query( $q_ins10 );

      			  $q_ins11 ="insert  temp(e_brokerage_redi,acc_no) select sum(abs(cast(t1.trade_quantity as decimal(13,5))))*.001,'$acc'   from Table_1 t1,Table_5 t5  where (( t1.account_no like '$acc%') and (t1.row_count = t5.row_count )  and (t1.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

      			  $r_ins11 = mssql_query( $q_ins11 );

		          $q_ins12 ="insert  temp(e_brokerage_iq,acc_no) select sum(abs(cast(t1.trade_quantity as decimal(13,5))))*.0011,'$acc' from Table_1 t1,Table_5 t5  where (( t1.account_no like '$acc%') and (t1.row_count = t5.row_count )  and (t1.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

		          $r_ins12 = mssql_query( $q_ins12 );

		          $q_ins13 ="insert  temp(e_options,acc_no) select sum(abs(cast(t1.trade_quantity as decimal(13,5)))),'$acc'   from Table_1 t1,Table_5 t5  where (( t1.account_no like '$acc%') and (t1.row_count = t5.row_count )  and (t5.journel_code ='OPT') and (t1.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

		          $r_ins13 = mssql_query( $q_ins13 );

		          $q_ins14 ="insert  temp(e_options_brokerage,acc_no) select sum(abs(cast(t1.trade_quantity as decimal(13,5)))),'$acc'   from Table_1 t1,Table_5 t5  where (( t1.account_no like '$acc%') and (t1.row_count = t5.row_count )  and (t5.journel_code ='OBR') and (t1.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

		          $r_ins14 = mssql_query( $q_ins14 );

		          $q_ins15 ="insert  temp(e_futures,acc_no) select '0','$acc'   from Table_1 t1  where (( t1.account_no like '$acc%') and (t1.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

              $r_ins15 = mssql_query( $q_ins15 );

		          $q_ins30="insert  temp(tmp.e_software_mkt_data,tmp.e_misc,acc_no) select avg(m.software_market_data),avg(m.misc),'$acce' from Table_1 t1,Table_5 t5 ,manual_data m where ((( t5.account_no = '$acce' and m.account_no = '$acce') and (t1.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2') and (m.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2')))";

		          $r_ins30 = mssql_query( $q_ins30 );

/*		          $q__ins31="select sum(abs(cast(tmp.i_total_revenue as decimal(15,5))))-sum(abs(cast(tmp.e_total_expenses as decimal(15,5)))) from expense cl, temp tmp where tmp.acc_no=cl.account_no";

		          $r_ins31 = mssql_query( $q_ins31 );

		          if ($r_ins31) {

              echo "<br>ho gaya ji ho gaya";

              } 

              else {

  print "Error running query: $q_ins31<br>\n";

}*/

		          

			  }
 

			$qsel7="select acc_no from bofa b where ((b.acc_no like '7%') or (b.acc_no like '4%'))";

			$rsel7 = mssql_query($qsel7);

			while($rowsel7 = mssql_fetch_array($rsel7))

  			  {

//  			  echo "<br>Populating ECN fees for Prime Accounts";

  			  $acce=$rr['acc_no'];

  			  $q_ins16 = "insert temp(e_ecn_fees,acc_no) select abs(cast(bofa.exec_share as decimal(13,5)))*(.0026),'$acce' from bofa_table_1 bofa where (( bofa.account_no like '$acce%') and (bofa.route ='ARCA') and (bofa.liquidity ='R') and (bofa.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

  			  $r_ins16 = mssql_query( $q_ins16 );

          $q_ins17 = "insert temp(e_ecn_fees,acc_no) select abs(cast(bofa.exec_share as decimal(13,5)))*(.0030),'$acce' from bofa_table_1 bofa where (( bofa.account_no like '$acce%' ) and (bofa.route ='ARCA') and (bofa.liquidity ='X') and (bofa.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

          $r_ins17 = mssql_query( $q_ins17 );

  			  $q_ins18 = "insert temp(e_ecn_fees,acc_no) select abs(cast(bofa.exec_share as decimal(13,5)))*(-.0020),'$acce' from bofa_table_1 bofa where (( bofa.account_no like '$acce%') and (bofa.route ='ARCA') and (bofa.liquidity ='A') and (bofa.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

  	 		  $r_ins18 = mssql_query( $q_ins18 );

          $q_ins19 = "insert temp(e_ecn_fees,acc_no) select abs(cast(bofa.exec_share as decimal(13,5)))*(.0030),'$acce' from bofa_table_1 bofa where (( bofa.account_no like '$acce%') and (bofa.route ='ISLD') and (bofa.liquidity ='R') and (bofa.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

          $r_ins19 = mssql_query( $q_ins19 );

	        $q_ins20 = "insert temp(e_ecn_fees,acc_no) select abs(cast(bofa.exec_share as decimal(13,5)))*(.0040),'$acce' from bofa_table_1 bofa where (( bofa.account_no like '$acce%') and (bofa.route ='ISLD') and (bofa.liquidity ='X') and (bofa.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

	        $r_ins20 = mssql_query( $q_ins20 );

	        $q_ins21 = "insert temp(e_ecn_fees,acc_no) select abs(cast(bofa.exec_share as decimal(13,5)))*(-.0020),'$acce' from bofa_table_1 bofa where (( bofa.account_no like '$acce%') and (bofa.route ='ISLD') and (bofa.liquidity ='A') and (bofa.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

	        $r_ins21 = mssql_query( $q_ins21 );

	        $q_ins22 = "insert temp(e_ecn_fees,acc_no) select abs(cast(bofa.exec_share as decimal(13,5)))*(.0030),'$acce' from bofa_table_1 bofa where (( bofa.account_no like '$acce%') and (bofa.route ='BATS') and (bofa.liquidity ='R') and (bofa.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

	        $r_ins22 = mssql_query( $q_ins22 );

	        $q_ins23 = "insert temp(e_ecn_fees,acc_no) select abs(cast(bofa.exec_share as decimal(13,5)))*(.0030),'$acce' from bofa_table_1 bofa where (( bofa.account_no like '$acce%') and (bofa.route ='BATS') and (bofa.liquidity ='X') and (bofa.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

	        $r_ins23 = mssql_query( $q_ins23 );

	        $q_ins24 = "insert temp(e_ecn_fees,acc_no) select abs(cast(bofa.exec_share as decimal(13,5)))*(-.0020),'$acce' from bofa_table_1 bofa where (( bofa.account_no like '$acce%') and (bofa.route ='BATS') and (bofa.liquidity ='A') and (bofa.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

	        $r_ins24 = mssql_query( $q_ins24 );

	        $q_ins25 = "insert temp(e_ecn_fees,acc_no) select abs(cast(bofa.exec_share as decimal(13,5)))*(.0026),'$acce' from bofa_table_1 bofa where (( bofa.account_no like '$acce%') and (bofa.route ='EDGE') and (bofa.liquidity ='R') and (bofa.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

	        $r_ins25 = mssql_query( $q_ins25 );

	        $q_ins26 = "insert temp(e_ecn_fees,acc_no) select abs(cast(bofa.exec_share as decimal(13,5)))*(.0029),'$acce' from bofa_table_1 bofa where (( bofa.account_no like '$acce%') and (bofa.route ='EDGE') and (bofa.liquidity ='X') and (bofa.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

	        $r_ins26 = mssql_query( $q_ins26 );

	        $q_ins27 = "insert temp(e_ecn_fees,acc_no) select abs(cast(bofa.exec_share as decimal(13,5)))*(-.0025),'$acce' from bofa_table_1 bofa where (( bofa.account_no like '$acce%') and (bofa.route ='EDGE') and (bofa.liquidity ='A') and (bofa.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

	        $r_ins27 = mssql_query( $q_ins27 );

	        $q_ins28 = "insert temp(e_ecn_fees,acc_no) select abs(cast(bofa.exec_share as decimal(13,5)))*(.0026),'$acce' from bofa_table_1 bofa where (( bofa.account_no like '$acce%') and (bofa.route ='NYSE') and (bofa.liquidity ='R') and (bofa.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

	        $r_ins28 = mssql_query( $q_ins28 );

	        $q_ins29 = "insert temp(e_ecn_fees,acc_no) select abs(cast(bofa.exec_share as decimal(13,5)))*(.0026),'$acce' from bofa_table_1 bofa where (( bofa.account_no like '$acce%') and (bofa.route ='AMEX') and (bofa.liquidity ='R') and (bofa.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

	        $r_ins29 = mssql_query( $q_ins29 );

		  	  }
 

			$qsel8="select * from acc";// where account_no like'4%' or account_no like '7%'";

			$rselect=mssql_query($qsel8);

			while($rowselect = mssql_fetch_array($rselect))

			  {

//			  			  echo "<br>Populating SRC from all of Temp";

			  $ac = $rowselect['account_no'];

			  $fname =$rowselect['fund_name'];

			  $sales=$rowselect['rep'];

			  $type=$rowselect['type'];

			  $query_final="insert into src(acc_no  ,fund_name ,v_equity ,v_options ,v_futures ,v_id ,i_net_equity ,i_interest_financing ,i_short_stock_financing ,i_total_commissions ,i_options_clearance ,i_id_tickets ,i_futures_revenue ,i_algo_credit ,i_misc ,i_total_before_soft_dollar ,i_soft_dollar ,i_total_revenue ,e_ticket_charges ,e_id_ticket_charges ,e_brokerage_redi ,e_brokerage_iq ,e_pipeline ,e_options ,e_options_brokerage ,e_futures ,e_ecn_fees ,e_software_mkt_data ,e_algo_debit ,e_misc ,e_total_expenses ,t_income_from_trading ,t_income_from_financing ,t_total_income ,o_type ,o_sales_rep) select '$ac','$fname' ,sum(abs(cast(t1.v_equity as decimal(13,5)))),sum(abs(cast(t1.v_options as decimal(13,5)))),sum(abs(cast(t1.v_futures as decimal(13,5)))),sum(abs(cast(t1.v_id as decimal(13,5)))),sum(abs(cast(t1.i_net_equity as decimal(13,5)))),sum(abs(cast(t1.i_interest_financing as decimal(13,5)))),sum(abs(cast(t1.i_short_stock_financing as decimal(13,5)))),sum(abs(cast(t1.i_total_commissions as decimal(13,5)))),sum(abs(cast(t1.i_options_clearance as decimal(13,5)))),sum(abs(cast(t1.i_id_tickets as decimal(13,5)))),sum(abs(cast(t1.i_futures_revenue as decimal(13,5)))),sum(abs(cast(t1.i_algo_credit as decimal(13,5)))),sum(abs(cast(t1.i_misc as decimal(13,5)))),sum(abs(cast(t1.i_total_before_soft_dollar as decimal(13,5)))),sum(abs(cast(t1.i_soft_dollar as decimal(13,5)))),sum(abs(cast(t1.i_total_revenue as decimal(13,5)))),sum(abs(cast(t1.e_ticket_charges as decimal(13,5)))),sum(abs(cast(t1.e_id_ticket_charges as decimal(13,5)))),sum(abs(cast(t1.e_brokerage_redi as decimal(13,5)))),sum(abs(cast(t1.e_brokerage_iq as decimal(13,5)))),sum(abs(cast(t1.e_pipeline as decimal(13,5)))),sum(abs(cast(t1.e_options as decimal(13,5)))),sum(abs(cast(t1.e_options_brokerage as decimal(13,5)))),sum(abs(cast(t1.e_futures as decimal(13,5)))),sum(abs(cast(t1.e_ecn_fees as decimal(13,5)))),sum(abs(cast(t1.e_software_mkt_data as decimal(13,5)))),sum(abs(cast(t1.e_algo_debit as decimal(13,5)))),sum(abs(cast(t1.e_misc as decimal(13,5)))),sum(abs(cast(t1.e_total_expenses as decimal(13,5)))),sum(abs(cast(t1.t_income_from_trading as decimal(13,5)))),sum(abs(cast(t1.t_income_from_financing as decimal(13,5)))),sum(abs(cast(t1.t_total_income as decimal(13,5)))),'$type','$sales' from temp t1 where (t1.acc_no='$ac')";

			  $result_final=mssql_query($query_final);

			  }

//include("http://10.10.20.10:8000/test1/abc.aspx");

$q1_shrink = "ALTER DATABASE alaris SET RECOVERY SIMPLE";

$q2_shrink = "DBCC SHRINKFILE (alaris_log, 100); ALTER DATABASE alaris SET RECOVERY FULL";

$r1_shrink = mssql_query($q1_shrink);

$r2_shrink = mssql_query($q2_shrink);

?>

<html>

<head>

</head>

<body>

Report Ready

<br>Click <a href="http://10.10.20.10:8000/test1/abc.aspx" target="_blank">here</a> to view the report

</body>

</html>

Open in new window

src.txt
0
Comment
Question by:jhawarmayank
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 34

Accepted Solution

by:
Beverley Portlock earned 500 total points
Comment Utility
Put this as the first lines of code

<?php
 
error_reporting(E_ALL);


include("connect.php");
$mo1 = $_POST['select1'];
$dy1 = $_POST['select2'];


Do you get an error message? If so post it here.
0
 

Author Comment

by:jhawarmayank
Comment Utility
yeah it reported some errors and i have corrected them
but still it is breaking but a little later in line number 163

0
 
LVL 34

Expert Comment

by:Beverley Portlock
Comment Utility
How do you know it is "breaking" at line 163? Are there more error codes being displayed and is Line 163 in the current version still the same as line 163 posted above - if you have added or removed lines then the line numbers will have changed.
0
 
LVL 82

Expert Comment

by:hielo
Comment Utility
Line 168 of your original post:
                    $acci = $row['account_no'];

it should be:
                    $acci = $rowsel4['account_no'];

>>yeah it reported some errors and i have corrected them
Where's the "corrected" code?
0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 

Author Comment

by:jhawarmayank
Comment Utility
this is the corrected code
now it breaks at line 163 according to the new code
<?php
 

include("connect.php");

$mo1 = $_POST['select1'];

$dy1 = $_POST['select2'];

$yr1 = $_POST['select3'];

$mo2 = $_POST['select4'];

$dy2 = $_POST['select5'];

$yr2 = $_POST['select6'];
 

                      $qdel = "truncate table temp; DBCC CHECKIDENT('temp', reseed, 0)";

                      $rdel = mssql_query($qdel);

                      $qdel2 = "delete from src";

                      $rdel2 = mssql_query($qdel2);

                      $qdel3 = "delete from bofa";

                      $rdel3 = mssql_query($qdel3);

                      $qdel4 = "delete from income";

                      $rdel4 = mssql_query($qdel4);

                      $qdel5 = "delete from expense";

                      $rdel5 = mssql_query($qdel5);

//echo "<br>populate Income,Expense and Bofa Table";

                      $qpieb1 = "insert bofa(acc_no) select distinct(b.account_no) from bofa_table_1 b where (b.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2')";

                      $rpieb1 = mssql_query($qpieb1);

                      $qpieb2 = "insert income(account_no) select right(t5.trailer_1,8) from Table_5 t5 where ((t5.account_no like '4W7F%') and (t5.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

                      $rpieb2 = mssql_query($qpieb2);

                      $qpieb3 = "insert expense(account_no) select right(t5.trailer_1,8) from Table_5 t5 where ((t5.account_no like '4W7G%') and (t5.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

                      $rpieb3 = mssql_query($qpieb3);

//echo "<br>Update Income,Expense and Bofa Table";

                      $quieb1 = "update bofa set acc_no=substring(acc_no,1,4) from bofa where (acc_no like '4%' or acc_no like '7%')";

                      $ruieb1 = mssql_query($quieb1);

                      $quieb2 = "update income set account_no=substring(account_no,1,4) from income where (account_no like '4%' or account_no like '7%')";

                      $ruieb2 = mssql_query($quieb2);

                      $quieb3 = "delete from income where account_no like '74TV'";

                      $ruieb3 = mssql_query($quieb3);

                      $quieb4 = "update expense set account_no=substring(account_no,1,4) from expense where (account_no like '4%' or account_no like '7%')";

                      $ruqib4 = mssql_query($quieb4);

                      $quieb5 = "delete from expense where account_no like '74TV'";

                      $ruieb5 = mssql_query($quieb5);
 

                      $qsel1 = "select account_no from acc where account_no like '5%5'";

                      $rsel1 = mssql_query($qsel1);

                      while($rowsel1 = mssql_fetch_array($rsel1))

  			{

//  			echo "<br>Populate Volume for DVP";

      				$acci = $rowsel1['account_no'];

      				$q_ins1 = "insert temp(v_equity,v_options,v_futures,v_id,acc_no) select sum(abs(cast(t1.trade_quantity as decimal(13,5)))),'0','0','0','$acci' from Table_1 t1,Table_5 t5 where ((t1.account_no like '$acci') and (t1.row_count = t5.row_count) and (t1.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

      				$r_ins1 = mssql_query($q_ins1);

			} 
 

			$qsel2 = "select cl.account_no from acc cl where cl.account_no like '5%5'";

			$rsel2 = mssql_query($qsel2);

			while($rowsel2 = mssql_fetch_array($rsel2))

			{

//			echo "<br>Populate Income columns for DVP";

				$acci = $rowsel2['account_no'];
 

/*

For the time being till we figure it out
 

				    $q_ins2 = "insert temp(i_net_equity,acc_no) select '0','$acci' from Table_1 t1  where (( t1.account_no like '$acci') and (t1.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

			      $r_ins2 = mssql_query($q_ins2);

			      $q_ins3 = "insert temp(i_interest_financing,acc_no) select '0','$acci' from Table_1 t1  where (( t1.account_no like '$acci') and (t1.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

			      $r_ins3 = mssql_query( $q_ins3 );

			      $q_ins4 = "insert temp(i_short_stock_financing,acc_no) select '0','$acci' from Table_1 t1  where (( t1.account_no like '$acci') and (t1.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

			      $r_ins4 = mssql_query( $q_ins4 );
 

*/

			      

			      $q_ins5 = "insert temp(i_total_commissions,acc_no) select sum(abs(t2.local_clearence_charges_1)),'$acci'   from dbo.Table_2 t2,Table_5 t5  where (( t2.account_no like '$acci') and ( t2.row_count=t5.row_count )  and (t2.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

			      $r_ins5 = mssql_query( $q_ins5 );

			      $q_ins6 = "insert temp(i_options_clearance,acc_no) select sum(abs(cast(t1.trade_quantity as decimal(13,5)))),'$acci'   from Table_1 t1,Table_5 t5  where ((t1.account_no like '$acci') and (t5.journel_code = 'OPT') and (t1.row_count = t5.row_count ) and (t1.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

			      $r_ins6 = mssql_query( $q_ins6 );

			      $q_ins7 = "insert temp(i_id_tickets,acc_no) select sum(abs(cast(t1.trade_quantity as decimal(13,5)))),'$acci'   from Table_1 t1,Table_5 t5  where ((t1.account_no like '$acci') and (t5.journel_code = 'IDC') and (t1.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

			      $r_ins7 = mssql_query( $q_ins7 );

			      $q_ins8 = "insert temp(i_futures_revenue,i_algo_credit,i_misc,i_soft_dollar,acc_no) select m.software_market_data,'0',m.misc,m.soft_dollar,'$acci' from manual_data m where ((m.account_no like '$acci') and (m.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

			      $r_ins8 = mssql_query( $q_ins8 );

			      $q_ins9 = "insert temp(tmp.i_total_before_soft_dollar,acc_no) select sum(abs(cast(tmp.i_total_commissions as decimal(13, 5))) + abs(cast(tmp.i_options_clearance as decimal(13,5))) + abs(cast(tmp.i_id_tickets as decimal(13,5))) + abs(cast(tmp.i_futures_revenue as decimal(15,5))) + abs(cast(tmp.i_algo_credit as decimal(15,5))) + abs(cast(tmp.i_misc as decimal(15,5)))),'$acci' from temp tmp where (acc_no like '$acci')";

			      $r_ins9 = mssql_query( $q_ins9 );

			} 				
 

			$qsel2 = "select account_no from expense where account_no like '5%5'";

			$rsel2 = mssql_query($qsel2);

			while($rowsel2 = mssql_fetch_array($rsel2))

			{

//			echo "<br>Populate Expense columns for DVP";

			      $acce = $row['account_no'];

			      print_r($rowsel2);

			      echo "$acce";

			      $q_ins9  = "insert temp(e_ticket_charges,acc_no) select sum(abs(cast(t1.trade_quantity as decimal(13,5)))),'$acce' from Table_1 t1,Table_5 t5  where ((t1.account_no like '$acce') and (t1.row_count = t5.row_count ) and (t5.journel_code = 'CLR') and (t1.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

			      $r_ins9  = mssql_query( $q_ins9 );

			      $q_ins10 = "insert temp(e_id_ticket_charges,acc_no) select sum(abs(cast(t1.trade_quantity as decimal(13,5)))),'$acce' from Table_1 t1,Table_5 t5  where ((t1.account_no like  '$acce') and (t5.journel_code = 'IDC') and (t1.row_count = t5.row_count ) and (t1.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

			      $r_ins10 = mssql_query( $q_ins10 );

			      $q_ins11 = "insert temp(e_brokerage_redi,acc_no) select abs(cast(t1.trade_quantity as decimal(13,5)))*(.001),'$acce' from Table_1 t1,Table_5 t5  where (( t1.account_no like '$acce') and (t1.row_count = t5.row_count ) and (t1.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

			      $r_ins11 = mssql_query( $q_ins11 );

			      $q_ins12 = "insert temp(e_brokerage_iq,acc_no) select sum(abs(cast(t1.trade_quantity as decimal(13,5))))*(.0011),'$acce' from Table_1 t1,Table_5 t5  where (( t1.account_no like '$acce') and (t1.row_count = t5.row_count ) and (t1.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

			      $r_ins12 = mssql_query( $q_ins12 );

			      $q_ins13 = "insert temp(e_options,acc_no) select sum(abs(cast(t1.trade_quantity as decimal(13,5)))),'$acce'   from Table_1 t1,Table_5 t5  where (( t1.account_no like '$acce') and (t5.journel_code ='OPT') and (t1.row_count = t5.row_count ) and (t1.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

			      $r_ins13 = mssql_query( $q_ins13 );

			      $q_ins14 = "insert temp(e_options_brokerage,acc_no) select sum(abs(cast(t1.trade_quantity as decimal(13,5)))),'$acce'   from Table_1 t1,Table_5 t5  where (( t1.account_no like '$acce') and (t5.journel_code ='OBR') and (t1.row_count = t5.row_count ) and (t1.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

			      $r_ins14 = mssql_query( $q_ins14 );

			      $q_ins15 = "insert temp(e_futures,acc_no) select '0','$acce'   from Table_1 t1 where (( t1.account_no like '$acce' ) and (t1.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

			      $r_ins15 = mssql_query( $q_ins15 );

			      $q_ins30 = "insert temp(tmp.e_software_mkt_data,tmp.e_misc,acc_no) select avg(m.software_market_data),avg(m.misc),'$acce' from manual_data m where (( m.account_no like '$acce') and (m.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$y2-$yr2'))";

			      $r_ins30 = mssql_query( $q_ins30 );

		              $q_ins31="select sum(abs(cast(tmp.i_total_revenue as decimal(15,5)))) - sum(abs(cast(tmp.e_total_expenses as decimal(15,5)))) from client_table cl, temp tmp where tmp.acc_no like cl.account_no";

		              $r_ins31 = mssql_query( $q_ins31 );

			}
 

			$qsel3="select account_no from acc b where b.account_no like '5%5'";

			echo $qsel3;

			$rsel3 = mssql_query($qsel2);

			while($rowsel3 = mssql_fetch_array($rsel3))

			  {

			  echo "in here";

//			  echo "<br>Populate ECN fees for DVP";

			      $acce=$rowsel3['acc_no'];

			      print_r($rowsel3);

			      $q_ins16 = "insert temp(e_ecn_fees,acc_no) select abs(cast(bofa.exec_share as decimal(13,5)))*(.0026),'$acce' from bofa_table_1 bofa where (( bofa.account_no like '$acce') and (bofa.route like 'ARCA') and (bofa.liquidity like 'R') and (bofa.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

			      $r_ins16 = mssql_query( $q_ins16 );

			      $q_ins17 = "insert temp(e_ecn_fees,acc_no) select abs(cast(bofa.exec_share as decimal(13,5)))*(.0030),'$acce' from bofa_table_1 bofa where (( bofa.account_no like '$acce' ) and (bofa.route like 'ARCA') and (bofa.liquidity like 'X') and (bofa.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

			      $r_ins17 = mssql_query( $q_ins17 );

			      $q_ins18 = "insert temp(e_ecn_fees,acc_no) select abs(cast(bofa.exec_share as decimal(13,5)))*(-.0020),'$acce' from bofa_table_1 bofa where (( bofa.account_no like '$acce') and (bofa.route like 'ARCA') and (bofa.liquidity like 'A') and (bofa.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

			      $r_ins18 = mssql_query( $q_ins18 );

			      $q_ins19 = "insert temp(e_ecn_fees,acc_no) select abs(cast(bofa.exec_share as decimal(13,5)))*(.0030),'$acce' from bofa_table_1 bofa where (( bofa.account_no like '$acce') and (bofa.route like 'ISLD') and (bofa.liquidity like 'R') and (bofa.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

			      $r_ins19 = mssql_query( $q_ins19 );

			      $q_ins20 = "insert temp(e_ecn_fees,acc_no) select abs(cast(bofa.exec_share as decimal(13,5)))*(.0040),'$acce' from bofa_table_1 bofa where (( bofa.account_no like '$acce') and (bofa.route like 'ISLD') and (bofa.liquidity like 'X') and (bofa.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

			      $r_ins20 = mssql_query( $q_ins20 );

			      $q_ins21 = "insert temp(e_ecn_fees,acc_no) select abs(cast(bofa.exec_share as decimal(13,5)))*(-.0020),'$acce' from bofa_table_1 bofa where (( bofa.account_no like '$acce') and (bofa.route like 'ISLD') and (bofa.liquidity like 'A') and (bofa.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

			      $r_ins21 = mssql_query( $q_ins21 );

			      $q_ins22 = "insert temp(e_ecn_fees,acc_no) select abs(cast(bofa.exec_share as decimal(13,5)))*(.0030),'$acce' from bofa_table_1 bofa where (( bofa.account_no like '$acce') and (bofa.route like 'BATS') and (bofa.liquidity like 'R') and (bofa.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

			      $r_ins22 = mssql_query( $q_ins22 );

			      $q_ins23 = "insert temp(e_ecn_fees,acc_no) select abs(cast(bofa.exec_share as decimal(13,5)))*(.0030),'$acce' from bofa_table_1 bofa where (( bofa.account_no like '$acce') and (bofa.route like 'BATS') and (bofa.liquidity like 'X') and (bofa.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

			      $r_ins23 = mssql_query( $q_ins23 );

			      $q_ins24 = "insert temp(e_ecn_fees,acc_no) select abs(cast(bofa.exec_share as decimal(13,5)))*(-.0020),'$acce' from bofa_table_1 bofa where (( bofa.account_no like '$acce') and (bofa.route like 'BATS') and (bofa.liquidity like 'A') and (bofa.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

			      $r_ins24 = mssql_query( $q_ins24 );

			      $q_ins25 = "insert temp(e_ecn_fees,acc_no) select abs(cast(bofa.exec_share as decimal(13,5)))*(.0026),'$acce' from bofa_table_1 bofa where (( bofa.account_no like '$acce') and (bofa.route like 'EDGE') and (bofa.liquidity like 'R') and (bofa.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

			      $r_ins25 = mssql_query( $q_ins25 );

			      $q_ins26 = "insert temp(e_ecn_fees,acc_no) select abs(cast(bofa.exec_share as decimal(13,5)))*(.0029),'$acce' from bofa_table_1 bofa where (( bofa.account_no like '$acce') and (bofa.route like 'EDGE') and (bofa.liquidity like 'X') and (bofa.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

			      $r_ins26 = mssql_query( $q_ins26 );

			      $q_ins27 = "insert temp(e_ecn_fees,acc_no) select abs(cast(bofa.exec_share as decimal(13,5)))*(-.0025),'$acce' from bofa_table_1 bofa where (( bofa.account_no like '$acce') and (bofa.route like 'EDGE') and (bofa.liquidity like 'A') and (bofa.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

			      $r_ins27 = mssql_query( $q_ins27 );

			      $q_ins28 = "insert temp(e_ecn_fees,acc_no) select abs(cast(bofa.exec_share as decimal(13,5)))*(.0026),'$acce' from bofa_table_1 bofa where (( bofa.account_no like '$acce') and (bofa.route like 'NYSE') and (bofa.liquidity like 'R') and (bofa.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

			      $r_ins28 = mssql_query( $q_ins28 );

			      $q_ins29 = "insert temp(e_ecn_fees,acc_no) select abs(cast(bofa.exec_share as decimal(13,5)))*(.0026),'$acce' from bofa_table_1 bofa where (( bofa.account_no like '$acce') and (bofa.route like 'AMEX') and (bofa.liquidity like 'R') and (bofa.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

			      $r_ins29 = mssql_query( $q_ins29 );

			   }

/*$qsel8="select * from acc where account_no like '5%5'";

			$rsel8=mssql_query($qsel8);

			while($rowsel8 = mssql_fetch_array($rsel8))

			  {

			  			  

			  $ac = $rowsel8['account_no'];

			  $fname =$rowsel8['fund_name'];

			  $sales=$rowsel8['rep'];

			  $type=$rowsel8['type'];

			  $query_final="insert into src(acc_no  ,fund_name ,v_equity ,v_options ,v_futures ,v_id ,i_net_equity ,i_interest_financing ,i_short_stock_financing ,i_total_commissions ,i_options_clearance ,i_id_tickets ,i_futures_revenue ,i_algo_credit ,i_misc ,i_total_before_soft_dollar ,i_soft_dollar ,i_total_revenue ,e_ticket_charges ,e_id_ticket_charges ,e_brokerage_redi ,e_brokerage_iq ,e_pipeline ,e_options ,e_options_brokerage ,e_futures ,e_ecn_fees ,e_software_mkt_data ,e_algo_debit ,e_misc ,e_total_expenses ,t_income_from_trading ,t_income_from_financing ,t_total_income ,o_type ,o_sales_rep) select '$ac','$fname' ,sum(abs(cast(t1.v_equity as decimal(13,5)))),sum(abs(cast(t1.v_options as decimal(13,5)))),sum(abs(cast(t1.v_futures as decimal(13,5)))),sum(abs(cast(t1.v_id as decimal(13,5)))),sum(abs(cast(t1.i_net_equity as decimal(13,5)))),sum(abs(cast(t1.i_interest_financing as decimal(13,5)))),sum(abs(cast(t1.i_short_stock_financing as decimal(13,5)))),sum(abs(cast(t1.i_total_commissions as decimal(13,5)))),sum(abs(cast(t1.i_options_clearance as decimal(13,5)))),sum(abs(cast(t1.i_id_tickets as decimal(13,5)))),sum(abs(cast(t1.i_futures_revenue as decimal(13,5)))),sum(abs(cast(t1.i_algo_credit as decimal(13,5)))),sum(abs(cast(t1.i_misc as decimal(13,5)))),sum(abs(cast(t1.i_total_before_soft_dollar as decimal(13,5)))),sum(abs(cast(t1.i_soft_dollar as decimal(13,5)))),sum(abs(cast(t1.i_total_revenue as decimal(13,5)))),sum(abs(cast(t1.e_ticket_charges as decimal(13,5)))),sum(abs(cast(t1.e_id_ticket_charges as decimal(13,5)))),sum(abs(cast(t1.e_brokerage_redi as decimal(13,5)))),sum(abs(cast(t1.e_brokerage_iq as decimal(13,5)))),sum(abs(cast(t1.e_pipeline as decimal(13,5)))),sum(abs(cast(t1.e_options as decimal(13,5)))),sum(abs(cast(t1.e_options_brokerage as decimal(13,5)))),sum(abs(cast(t1.e_futures as decimal(13,5)))),sum(abs(cast(t1.e_ecn_fees as decimal(13,5)))),sum(abs(cast(t1.e_software_mkt_data as decimal(13,5)))),sum(abs(cast(t1.e_algo_debit as decimal(13,5)))),sum(abs(cast(t1.e_misc as decimal(13,5)))),sum(abs(cast(t1.e_total_expenses as decimal(13,5)))),sum(abs(cast(t1.t_income_from_trading as decimal(13,5)))),sum(abs(cast(t1.t_income_from_financing as decimal(13,5)))),sum(abs(cast(t1.t_total_income as decimal(13,5)))),'$type','$sales' from temp t1 where (t1.acc_no='$ac')";

			  $result_final=mssql_query($query_final);

			  }

//        $qdel = "truncate table temp; DBCC CHECKIDENT('temp', reseed, 0)";

//        $rdel = mssql_query($qdel);

*/			

echo "Done for DVP<br>";

			$qsel4 = "select account_no from acc cl where account_no like '4%' or account_no like '7%'";

			$rsel4 = mssql_query($qsel4);

			while($rowsel4 = mssql_fetch_array($rsel4))

			  {

//			  echo "<br>Populating Volumes for Prime Accounts";

			  $acci = $row['account_no'];

			  $q_ins1  = "insert temp(v_equity,acc_no) select sum(abs(cast(t1.trade_quantity as decimal(13,5)))),'$acci' from Table_1 t1,Table_5 t5  where ((t1.account_no = '".$acci."1209')  and (t1.row_count = t5.row_count ) and (t1.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

			  $r_ins1  = mssql_query( $q_ins1 );

			  $q_ins2  = "insert temp(v_options,acc_no) select sum(abs(cast(t1.trade_quantity as decimal(13,5)))),'$acci' from Table_1 t1,Table_5 t5  where ((t1.account_no = '".$acci."0409') and (t1.row_count = t5.row_count )  and (t1.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

			  $r_ins1  = mssql_query( $q_ins1 );

			  $q_ins3  = "insert temp(v_futures,acc_no) select sum(abs(cast(t1.trade_quantity as decimal(13,5)))),'$acci' from Table_1 t1,Table_5 t5  where ((t1.account_no = '".$acci."F909') and (t1.row_count = t5.row_count )  and (t1.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

			  $r_ins3  = mssql_query( $q_ins3 );

			  $q_ins4  = "insert temp(v_id,acc_no) select '0','$acci' from Table_1 t1,Table_5 t5  where ((t1.account_no like '$acci') and (t1.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

			  $r_ins4  = mssql_query( $q_ins4 );

			  }
 

			$qsel5 = "select cl.account_no from income cl where ((cl.account_no like '4%') or (cl.account_no like '7%'))";

			$rsel5 = mssql_query($qsel5);

			while ($rowsel5 = mssql_fetch_array($rsel5))

			  {

//			  echo "<br>Populating Income for Prime Accounts";

			  $acci = $row['account_no'];

			  $q_ins5  = "insert  temp(i_net_equity,acc_no) select '0','$acci' from Table_1 t1  where (( t1.account_no like '$acci%')  and (t1.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

			  $r_ins5  = mssql_query( $q_ins5 );

      			  $q_ins6  = "insert  temp(i_interest_financing,acc_no) select '0','$acci' from Table_1 t1  where (( t1.account_no like '$acci%') and (t1.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

      			  $r_ins6  = mssql_query( $q_ins6 );

      			  $q_ins7  = "insert  temp(i_short_stock_financing,acc_no) select '0','$acci' from Table_1 t1  where (( t1.account_no like '$acci%') and (t1.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

      			  $r_ins7  = mssql_query( $q_ins7 );

      			  $q_ins8  = "insert  temp(i_total_commissions,acc_no) select sum(abs(t2.local_clearence_charges_1)),'$acci' from Table_2 t2,Table_5 t5  where (( t2.account_no like '$acci%') and (t2.row_count = t5.row_count )  and (t2.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

      			  $r_ins8  = mssql_query( $q_ins8 );

      			  $q_ins9  = "insert  temp(i_options_clearance,acc_no) select sum(abs(cast(t1.trade_quantity as decimal(13,5)))),'$acci'   from Table_1 t1,Table_5 t5  where (( t1.account_no like '$acci%') and (t5.journel_code ='OPT') and (t1.row_count = t5.row_count )  and (t1.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

      			  $r_ins9  = mssql_query( $q_ins9 );

      			  $q_ins10 = "insert  temp(i_id_tickets,acc_no) select sum(abs(cast(t1.trade_quantity as decimal(13,5)))),'$acci'   from Table_1 t1,Table_5 t5  where (( t1.account_no like '$acci%') and (t1.row_count = t5.row_count )  and (t5.journel_code ='IDC') and (t1.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

      			  $r_ins10 = mssql_query( $q_ins10 );

      			  $q_ins11 = "insert  temp(i_futures_revenue,i_algo_credit,i_misc,i_soft_dollar,acc_no) select (m.software_market_data),'0',(m.misc),(m.soft_dollar),'$acci' from Table_1 t1,Table_5 t5 ,manual_data m where ((m.account_no = '$acci') and (m.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

      			  $r_ins11 = mssql_query( $q_ins11 );

      			  $q_ins12 = "insert temp(tmp.i_total_before_soft_dollar) select sum(abs(cast(tmp.i_total_commissions as decimal(13, 5))) + abs(cast(tmp.i_options_clearance as decimal(13,5))) + abs(cast(tmp.i_id_tickets as decimal(13,5))) + abs(cast(tmp.i_futures_revenue as decimal(15,5))) + abs(cast(tmp.i_algo_credit as decimal(15,5))) + abs(cast(tmp.i_misc as decimal(15,5)))) from temp tmp where acc_no ='$acci'";

      			  $r_ins12 = mssql_query( $q_ins12 );

			  }
 

			$qsel6="select * from expense where ((account_no like '4%') or (account_no like '7%'))";

			$rsel6=mssql_query($qsel6);

			while($row = mssql_fetch_array($rsel6))

			  {

//			  echo "<br>Populating Expenses for Prime Accounts";

			  $acc = $row['account_no'];

			  $q_ins9 ="insert  temp(e_ticket_charges,acc_no) select sum(abs(cast(t1.trade_quantity as decimal(13,5)))),'$acc'   from Table_1 t1,Table_5 t5  where ( (t1.account_no like '$acc%') and (t5.journel_code ='CLR')  and (t1.row_count = t5.row_count ) and (t1.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

			  $r_ins9  = mssql_query( $q_ins9 );

			  $q_ins10 ="insert  temp(e_id_ticket_charges,acc_no) select sum(abs(cast(t1.trade_quantity as decimal(13,5)))),'$acc'   from Table_1 t1,Table_5 t5  where (( t1.account_no like '$acc%') and (t5.journel_code ='IDC') and (t1.row_count=t5.row_count) and (t1.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

			  $r_ins10 = mssql_query( $q_ins10 );

      			  $q_ins11 ="insert  temp(e_brokerage_redi,acc_no) select sum(abs(cast(t1.trade_quantity as decimal(13,5))))*.001,'$acc'   from Table_1 t1,Table_5 t5  where (( t1.account_no like '$acc%') and (t1.row_count = t5.row_count )  and (t1.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

      			  $r_ins11 = mssql_query( $q_ins11 );

		          $q_ins12 ="insert  temp(e_brokerage_iq,acc_no) select sum(abs(cast(t1.trade_quantity as decimal(13,5))))*.0011,'$acc' from Table_1 t1,Table_5 t5  where (( t1.account_no like '$acc%') and (t1.row_count = t5.row_count )  and (t1.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

		          $r_ins12 = mssql_query( $q_ins12 );

		          $q_ins13 ="insert  temp(e_options,acc_no) select sum(abs(cast(t1.trade_quantity as decimal(13,5)))),'$acc'   from Table_1 t1,Table_5 t5  where (( t1.account_no like '$acc%') and (t1.row_count = t5.row_count )  and (t5.journel_code ='OPT') and (t1.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

		          $r_ins13 = mssql_query( $q_ins13 );

		          $q_ins14 ="insert  temp(e_options_brokerage,acc_no) select sum(abs(cast(t1.trade_quantity as decimal(13,5)))),'$acc'   from Table_1 t1,Table_5 t5  where (( t1.account_no like '$acc%') and (t1.row_count = t5.row_count )  and (t5.journel_code ='OBR') and (t1.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

		          $r_ins14 = mssql_query( $q_ins14 );

		          $q_ins15 ="insert  temp(e_futures,acc_no) select '0','$acc'   from Table_1 t1  where (( t1.account_no like '$acc%') and (t1.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

              $r_ins15 = mssql_query( $q_ins15 );

		          $q_ins30="insert  temp(tmp.e_software_mkt_data,tmp.e_misc,acc_no) select avg(m.software_market_data),avg(m.misc),'$acce' from Table_1 t1,Table_5 t5 ,manual_data m where ((( t5.account_no = '$acce' and m.account_no = '$acce') and (t1.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2') and (m.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2')))";

		          $r_ins30 = mssql_query( $q_ins30 );

/*		          $q__ins31="select sum(abs(cast(tmp.i_total_revenue as decimal(15,5))))-sum(abs(cast(tmp.e_total_expenses as decimal(15,5)))) from expense cl, temp tmp where tmp.acc_no=cl.account_no";

		          $r_ins31 = mssql_query( $q_ins31 );

		          if ($r_ins31) {

              echo "<br>ho gaya ji ho gaya";

              } 

              else {

  print "Error running query: $q_ins31<br>\n";

}*/

		          

			  }
 

			$qsel7="select acc_no from bofa b where ((b.acc_no like '7%') or (b.acc_no like '4%'))";

			$rsel7 = mssql_query($qsel7);

			while($rowsel7 = mssql_fetch_array($rsel7))

  			  {

//  			  echo "<br>Populating ECN fees for Prime Accounts";

  			  $acce=$rr['acc_no'];

  			  $q_ins16 = "insert temp(e_ecn_fees,acc_no) select abs(cast(bofa.exec_share as decimal(13,5)))*(.0026),'$acce' from bofa_table_1 bofa where (( bofa.account_no like '$acce%') and (bofa.route ='ARCA') and (bofa.liquidity ='R') and (bofa.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

  			  $r_ins16 = mssql_query( $q_ins16 );

          $q_ins17 = "insert temp(e_ecn_fees,acc_no) select abs(cast(bofa.exec_share as decimal(13,5)))*(.0030),'$acce' from bofa_table_1 bofa where (( bofa.account_no like '$acce%' ) and (bofa.route ='ARCA') and (bofa.liquidity ='X') and (bofa.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

          $r_ins17 = mssql_query( $q_ins17 );

  			  $q_ins18 = "insert temp(e_ecn_fees,acc_no) select abs(cast(bofa.exec_share as decimal(13,5)))*(-.0020),'$acce' from bofa_table_1 bofa where (( bofa.account_no like '$acce%') and (bofa.route ='ARCA') and (bofa.liquidity ='A') and (bofa.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

  	 		  $r_ins18 = mssql_query( $q_ins18 );

          $q_ins19 = "insert temp(e_ecn_fees,acc_no) select abs(cast(bofa.exec_share as decimal(13,5)))*(.0030),'$acce' from bofa_table_1 bofa where (( bofa.account_no like '$acce%') and (bofa.route ='ISLD') and (bofa.liquidity ='R') and (bofa.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

          $r_ins19 = mssql_query( $q_ins19 );

	        $q_ins20 = "insert temp(e_ecn_fees,acc_no) select abs(cast(bofa.exec_share as decimal(13,5)))*(.0040),'$acce' from bofa_table_1 bofa where (( bofa.account_no like '$acce%') and (bofa.route ='ISLD') and (bofa.liquidity ='X') and (bofa.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

	        $r_ins20 = mssql_query( $q_ins20 );

	        $q_ins21 = "insert temp(e_ecn_fees,acc_no) select abs(cast(bofa.exec_share as decimal(13,5)))*(-.0020),'$acce' from bofa_table_1 bofa where (( bofa.account_no like '$acce%') and (bofa.route ='ISLD') and (bofa.liquidity ='A') and (bofa.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

	        $r_ins21 = mssql_query( $q_ins21 );

	        $q_ins22 = "insert temp(e_ecn_fees,acc_no) select abs(cast(bofa.exec_share as decimal(13,5)))*(.0030),'$acce' from bofa_table_1 bofa where (( bofa.account_no like '$acce%') and (bofa.route ='BATS') and (bofa.liquidity ='R') and (bofa.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

	        $r_ins22 = mssql_query( $q_ins22 );

	        $q_ins23 = "insert temp(e_ecn_fees,acc_no) select abs(cast(bofa.exec_share as decimal(13,5)))*(.0030),'$acce' from bofa_table_1 bofa where (( bofa.account_no like '$acce%') and (bofa.route ='BATS') and (bofa.liquidity ='X') and (bofa.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

	        $r_ins23 = mssql_query( $q_ins23 );

	        $q_ins24 = "insert temp(e_ecn_fees,acc_no) select abs(cast(bofa.exec_share as decimal(13,5)))*(-.0020),'$acce' from bofa_table_1 bofa where (( bofa.account_no like '$acce%') and (bofa.route ='BATS') and (bofa.liquidity ='A') and (bofa.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

	        $r_ins24 = mssql_query( $q_ins24 );

	        $q_ins25 = "insert temp(e_ecn_fees,acc_no) select abs(cast(bofa.exec_share as decimal(13,5)))*(.0026),'$acce' from bofa_table_1 bofa where (( bofa.account_no like '$acce%') and (bofa.route ='EDGE') and (bofa.liquidity ='R') and (bofa.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

	        $r_ins25 = mssql_query( $q_ins25 );

	        $q_ins26 = "insert temp(e_ecn_fees,acc_no) select abs(cast(bofa.exec_share as decimal(13,5)))*(.0029),'$acce' from bofa_table_1 bofa where (( bofa.account_no like '$acce%') and (bofa.route ='EDGE') and (bofa.liquidity ='X') and (bofa.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

	        $r_ins26 = mssql_query( $q_ins26 );

	        $q_ins27 = "insert temp(e_ecn_fees,acc_no) select abs(cast(bofa.exec_share as decimal(13,5)))*(-.0025),'$acce' from bofa_table_1 bofa where (( bofa.account_no like '$acce%') and (bofa.route ='EDGE') and (bofa.liquidity ='A') and (bofa.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

	        $r_ins27 = mssql_query( $q_ins27 );

	        $q_ins28 = "insert temp(e_ecn_fees,acc_no) select abs(cast(bofa.exec_share as decimal(13,5)))*(.0026),'$acce' from bofa_table_1 bofa where (( bofa.account_no like '$acce%') and (bofa.route ='NYSE') and (bofa.liquidity ='R') and (bofa.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

	        $r_ins28 = mssql_query( $q_ins28 );

	        $q_ins29 = "insert temp(e_ecn_fees,acc_no) select abs(cast(bofa.exec_share as decimal(13,5)))*(.0026),'$acce' from bofa_table_1 bofa where (( bofa.account_no like '$acce%') and (bofa.route ='AMEX') and (bofa.liquidity ='R') and (bofa.todays_date between '$mo1-$dy1-$yr1' and '$mo2-$dy2-$yr2'))";

	        $r_ins29 = mssql_query( $q_ins29 );

		  	  }
 

			$qsel8="select * from acc";// where account_no like'4%' or account_no like '7%'";

			$rselect=mssql_query($qsel8);

			while($rowselect = mssql_fetch_array($rselect))

			  {

//			  			  echo "<br>Populating SRC from all of Temp";

			  $ac = $rowselect['account_no'];

			  $fname =$rowselect['fund_name'];

			  $sales=$rowselect['rep'];

			  $type=$rowselect['type'];

			  $query_final="insert into src(acc_no  ,fund_name ,v_equity ,v_options ,v_futures ,v_id ,i_net_equity ,i_interest_financing ,i_short_stock_financing ,i_total_commissions ,i_options_clearance ,i_id_tickets ,i_futures_revenue ,i_algo_credit ,i_misc ,i_total_before_soft_dollar ,i_soft_dollar ,i_total_revenue ,e_ticket_charges ,e_id_ticket_charges ,e_brokerage_redi ,e_brokerage_iq ,e_pipeline ,e_options ,e_options_brokerage ,e_futures ,e_ecn_fees ,e_software_mkt_data ,e_algo_debit ,e_misc ,e_total_expenses ,t_income_from_trading ,t_income_from_financing ,t_total_income ,o_type ,o_sales_rep) select '$ac','$fname' ,sum(abs(cast(t1.v_equity as decimal(13,5)))),sum(abs(cast(t1.v_options as decimal(13,5)))),sum(abs(cast(t1.v_futures as decimal(13,5)))),sum(abs(cast(t1.v_id as decimal(13,5)))),sum(abs(cast(t1.i_net_equity as decimal(13,5)))),sum(abs(cast(t1.i_interest_financing as decimal(13,5)))),sum(abs(cast(t1.i_short_stock_financing as decimal(13,5)))),sum(abs(cast(t1.i_total_commissions as decimal(13,5)))),sum(abs(cast(t1.i_options_clearance as decimal(13,5)))),sum(abs(cast(t1.i_id_tickets as decimal(13,5)))),sum(abs(cast(t1.i_futures_revenue as decimal(13,5)))),sum(abs(cast(t1.i_algo_credit as decimal(13,5)))),sum(abs(cast(t1.i_misc as decimal(13,5)))),sum(abs(cast(t1.i_total_before_soft_dollar as decimal(13,5)))),sum(abs(cast(t1.i_soft_dollar as decimal(13,5)))),sum(abs(cast(t1.i_total_revenue as decimal(13,5)))),sum(abs(cast(t1.e_ticket_charges as decimal(13,5)))),sum(abs(cast(t1.e_id_ticket_charges as decimal(13,5)))),sum(abs(cast(t1.e_brokerage_redi as decimal(13,5)))),sum(abs(cast(t1.e_brokerage_iq as decimal(13,5)))),sum(abs(cast(t1.e_pipeline as decimal(13,5)))),sum(abs(cast(t1.e_options as decimal(13,5)))),sum(abs(cast(t1.e_options_brokerage as decimal(13,5)))),sum(abs(cast(t1.e_futures as decimal(13,5)))),sum(abs(cast(t1.e_ecn_fees as decimal(13,5)))),sum(abs(cast(t1.e_software_mkt_data as decimal(13,5)))),sum(abs(cast(t1.e_algo_debit as decimal(13,5)))),sum(abs(cast(t1.e_misc as decimal(13,5)))),sum(abs(cast(t1.e_total_expenses as decimal(13,5)))),sum(abs(cast(t1.t_income_from_trading as decimal(13,5)))),sum(abs(cast(t1.t_income_from_financing as decimal(13,5)))),sum(abs(cast(t1.t_total_income as decimal(13,5)))),'$type','$sales' from temp t1 where (t1.acc_no='$ac')";

			  $result_final=mssql_query($query_final);

			  }

//include("http://10.10.20.10:8000/test1/abc.aspx");

$q1_shrink = "ALTER DATABASE alaris SET RECOVERY SIMPLE";

$q2_shrink = "DBCC SHRINKFILE (alaris_log, 100); ALTER DATABASE alaris SET RECOVERY FULL";

$r1_shrink = mssql_query($q1_shrink);

$r2_shrink = mssql_query($q2_shrink);

?>

<html>

<head>

</head>

<body>

Report Ready

<br>Click <a href="http://10.10.20.10:8000/test1/abc.aspx" target="_blank">here</a> to view the report

</body>

</html>

Open in new window

0
 
LVL 82

Expert Comment

by:hielo
Comment Utility
try:
$qsel4 = "select account_no from acc cl where cl.account_no like '4%' or cl.account_no like '7%'";

also, 168:
 $acci = $rowsel4['account_no'];
0
 
LVL 19

Expert Comment

by:NerdsOfTech
Comment Utility
Uncomment all debug echos and post html source
0
 

Author Comment

by:jhawarmayank
Comment Utility
there is no html source
its just a simple php page executing 100's of queries
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Consider the following scenario: You are working on a website and make something great - something that lets the server work with information submitted by your users. This could be anything, from a simple guestbook to a e-Money solution. But what…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to dynamically set the form action using jQuery.
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.

743 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now