Jump to content

how to sum integers after a loop


homer.favenir

Recommended Posts

it didnt work,

my script is like this

<?php
for($i = 2; $i <= $count_files; $i++)
{
	if(isset($qcfiles[$i]))
		{ ?>
       <?php echo "<tr><td>"; ?><h4><?php	echo $qcfiles[$i];?></h4><?php echo "</td></tr>"; ?>
	<?php	$file1 = file($kedir . "/" . $kefiles[$i]);
			$file2 = file($qcdir . "/" . $qcfiles[$i]);
			$file1_count = count($file1);
			$file2_count = count($file2);
			$count = 1;
			for($x = 0; $x <= $file1_count; $x++)
			{
			if(isset($file1[$x]) && isset($file2[$x]))
				{
					$vtag1 = substr($file1[$x],178,1);
					$vtag2 = substr($file2[$x],178,1);
					$page1 = substr($file1[$x],0,4);
					$page2 = substr($file2[$x],0,4);
					$type1 = substr($file1[$x],5,1);
					$type2 = substr($file2[$x],5,1);
					$name1 = substr($file1[$x],7,78);
					$name2 = substr($file2[$x],7,78);
					$ind1 = substr($file1[$x],0,1);
					$ind2 = substr($file2[$x],0,1);						
					$addr1 = substr($file1[$x], 1, 78);
					$addr2 = substr($file2[$x], 1, 78);
					$city1 = substr($file1[$x], 79, 30);
					$city2 = substr($file2[$x], 79, 30);
					$state1 = substr($file1[$x], 110, 2);
					$state2 = substr($file2[$x], 110, 2);
					$zc1 = substr($file1[$x], 112, 5);
					$zc2 = substr($file2[$x], 112, 5);
					$tf1 = substr($file1[$x], 123, 40);
					$tf2 = substr($file2[$x], 123, 40);
					$ac1 = substr($file1[$x], 164, 3);
					$ac2 = substr($file2[$x], 164, 3);
					$phone1  = substr($file1[$x], 168, 7);
					$phone2  = substr($file2[$x], 168, 7);

			 	if($vtag2 == 1)
			 		{ 
						$page_comp = strcmp($page1, $page2);
						$type_comp = strcmp($type1, $type2);
						$name_comp = strcmp($name1, $name2);
						if($page_comp != 0)
							{
								$err_stat = 1;
								$error = TRUE;
								$err_line = $count;
								$err_page1 = $page1;
								$err_page2 = $page2;?>
  <?php echo "<tr><td>"; ?> <?php echo "Line" . " " . $err_line;?><?php echo "</td>"; ?>
  <?php echo "<td>";?><?php echo "KE Page: " . " " . $err_page1 . "<br>" . "QC Page: " . " " . $err_page2; ?>
  <?php echo "<td>";?><?php if(isset($error)){$pageerror = 1;echo 1;}?><?php echo "</td>"; ?>
  <?php echo "<td>";?><?php if(!isset($error)){echo 1;}?><?php echo "</td>"; ?>
  <?php echo "</td></tr>"; ?> 
					<?php	}
}
}
}?>

 

i need my $pageerror to be sum up after the loop.

any idea guys?

 

thanks

Just before the loop, and then add a plus to the equal sign where it already says $pageerror = 1;

 

Don't know if it'll work, since your code is pretty messy.

 

<?php


$pageerror = 0;
for($i = 2; $i <= $count_files; $i++)



{





if(isset($qcfiles[$i]))







{ ?>
       <?php echo "<tr><td>"; ?><h4><?php



echo $qcfiles[$i];?></h4><?php echo "</td></tr>"; ?>





<?php



$file1 = file($kedir . "/" . $kefiles[$i]);









$file2 = file($qcdir . "/" . $qcfiles[$i]);









$file1_count = count($file1);









$file2_count = count($file2);









$count = 1;









for($x = 0; $x <= $file1_count; $x++)









{









if(isset($file1[$x]) && isset($file2[$x]))











{













$vtag1 = substr($file1[$x],178,1);













$vtag2 = substr($file2[$x],178,1);













$page1 = substr($file1[$x],0,4);













$page2 = substr($file2[$x],0,4);













$type1 = substr($file1[$x],5,1);













$type2 = substr($file2[$x],5,1);













$name1 = substr($file1[$x],7,78);













$name2 = substr($file2[$x],7,78);













$ind1 = substr($file1[$x],0,1);













$ind2 = substr($file2[$x],0,1);


























$addr1 = substr($file1[$x], 1, 78);













$addr2 = substr($file2[$x], 1, 78);













$city1 = substr($file1[$x], 79, 30);













$city2 = substr($file2[$x], 79, 30);













$state1 = substr($file1[$x], 110, 2);













$state2 = substr($file2[$x], 110, 2);













$zc1 = substr($file1[$x], 112, 5);













$zc2 = substr($file2[$x], 112, 5);













$tf1 = substr($file1[$x], 123, 40);













$tf2 = substr($file2[$x], 123, 40);













$ac1 = substr($file1[$x], 164, 3);













$ac2 = substr($file2[$x], 164, 3);













$phone1  = substr($file1[$x], 168, 7);













$phone2  = substr($file2[$x], 168, 7);























if($vtag2 == 1)















{ 















$page_comp = strcmp($page1, $page2);















$type_comp = strcmp($type1, $type2);















$name_comp = strcmp($name1, $name2);















if($page_comp != 0)

















{



















$err_stat = 1;



















$error = TRUE;



















$err_line = $count;



















$err_page1 = $page1;



















$err_page2 = $page2;?>
  <?php echo "<tr><td>"; ?> <?php echo "Line" . " " . $err_line;?><?php echo "</td>"; ?>
  <?php echo "<td>";?><?php echo "KE Page: " . " " . $err_page1 . "<br>" . "QC Page: " . " " . $err_page2; ?>
  <?php echo "<td>";?><?php if(isset($error)){$pageerror += 1;echo 1;}?><?php echo "</td>"; ?>
  <?php echo "<td>";?><?php if(!isset($error)){echo 1;}?><?php echo "</td>"; ?>
  <?php echo "</td></tr>"; ?> 













<?php



}
}
}
}?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.