Jump to content

Recommended Posts

hi,

how can i insert these code to table and echo the results to rows/columns

<pre>
<?php
$kebase = '//asecasianas2/DS_Keying/STATS/KE-DIR/';
$qcbase = '//asecasianas2/DS_Keying/STATS/QC-DIR/';
$dir = 'SC41001A';
$kedir = $kebase . $dir;
$qcdir = $qcbase . $dir;
$kefiles = scandir($kedir);
$qcfiles = scandir($qcdir);
$count_files = count($qcfiles);
echo $count_files . " " . "files found" . " " . "in" . " " . $dir . " " . "directory" . "<br>";

for($i = 2; $i <= $count_files; $i++)
{

	echo $qcfiles[$i] . "<br>";
	$file1 = file($kedir . "/" . $kefiles[$i]);
	$file2 = file($qcdir . "/" . $qcfiles[$i]);
	$file1_count = count($file1);
	$file2_count = count($file2);

	$count = 1;
	for($x = 0; $x <= $file2_count; $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);
		$name1 = substr($file1[$x],7,78);
		$name2 = substr($file2[$x],7,78);
		$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);
		$phone1  = substr($file1[$x], 164, 12);
		$phone2  = substr($file2[$x], 164, 12);
		if($vtag2 == 1)
		{
			$name_comp = strcmp($name1, $name2);
				if($name_comp != 0)
				{
					//echo "line".$count."error name" . "<br>";
					$err_stat = 1;
					$Error = 1;
					$err_line = $count;
					$err_name1 = $name1;
					$err_name2 = $name2;
					echo "Line" . $err_line . " " . "KE Name" . " " . $err_name1 . "<br> ";
					echo "       QC Name" . " " . $err_name2 . "<br>";
				}
		}else{
			$addr_comp = strcmp($addr1, $addr2);
			$city_comp = strcmp($city1, $city2);
			$state_comp = strcmp($state1, $state2);
			$zc_comp = strcmp($zc1, $zc2);
			$tf_comp = strcmp($tf1, $tf2);
			$phone_comp = strcmp($phone1, $phone2);
				if($addr_comp != 0)
				{
					$Error = 1;
					$err_line = $count;
					$err_addr1 = $addr1;
					$err_addr2 = $addr2;
					echo "Line" . $err_line . " " . "KE address" . " " . $err_addr1 . "<br>";
					echo "       QC address" . " " . $err_addr2 . "<br>";
				}
				if($city_comp != 0)
				{
					$Error = 1;
					$err_line = $count;
					$err_city1 = $city1;
					$err_city2 = $city2;
					echo "Line" . $err_line . " " . "KE City" . " " .  $err_city1 . "<br>";
					echo  "       QC City" . " " . $err_city2 . "<br>";
				}
				if($state_comp != 0)
				{
					$Error = 1;
					$err_line = $count;
					$err_state1 = $state1;
					$err_state2 = $state2;
					echo "Line" . $err_line . " " . "KE State" . " " .  $err_state1 . "<br>";
					echo  "       QC State" . " " . $err_state2 . "<br>";
				}
				if($zc_comp != 0)
				{
					$Error = 1;
					$err_line = $count;
					$err_zc1 = $zc1;
					$err_zc2 = $zc2;
					echo "Line" . $err_line . " " . "KE ZipCode" . " " .  $err_zc1 . "<br>";
					echo  "       QC ZipCode" . " " . $err_zc2 . "<br>";
				}
				if($tf_comp != 0)
				{
					$Error = 1;
					$err_line = $count;
					$err_tf1 = $tf1;
					$err_tf2 = $tf2;
					echo "Line" . $err_line . " " . "KE Toll Free Text" . " " .  $err_tf1 . "<br>";
					echo  "       QC Toll Free Text" . " " . $err_tf2 . "<br>";
				}
				if($phone_comp != 0)
				{
					$Error = 1;
					$err_line = $count;
					$err_phone1 = $phone1;
					$err_phone2 = $phone2;
					echo "Line" . $err_line . " " . "KE phone" . " " .  $err_phone1 . "<br>";
					echo  "       QC phone" . " " . $err_phone2 . "<br>";
				}

		}
		$count++;

	}

}

?>
</pre>

 

can anyone please help....

 

thanks

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/128819-solved-php-code-insert-to-table/
Share on other sites

Just a quick version but it should give you a starting point (but it also may work)

 

try this

*untested*

<?php
$kebase = '//asecasianas2/DS_Keying/STATS/KE-DIR/';
$qcbase = '//asecasianas2/DS_Keying/STATS/QC-DIR/';
$dir = 'SC41001A';
$kedir = $kebase . $dir;
$qcdir = $qcbase . $dir;
$kefiles = scandir($kedir);
$qcfiles = scandir($qcdir);
$count_files = count($qcfiles);
echo $count_files . " " . "files found" . " " . "in" . " " . $dir . " " . "directory" . "<br>";


echo "<table border=\"0\" >\n";
echo "<tr>\n";
echo "<td>Line</td>\n";
echo "<td>KE address</td>\n";
echo "<td>QC address</td>\n";
echo  "</tr>\n";

   for($i = 2; $i <= $count_files; $i++)
   {
         
      echo $qcfiles[$i] . "<br>";
      $file1 = file($kedir . "/" . $kefiles[$i]);
      $file2 = file($qcdir . "/" . $qcfiles[$i]);
      $file1_count = count($file1);
      $file2_count = count($file2);
      
      $count = 1;
      for($x = 0; $x <= $file2_count; $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);
         $name1 = substr($file1[$x],7,78);
         $name2 = substr($file2[$x],7,78);
         $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);
         $phone1  = substr($file1[$x], 164, 12);
         $phone2  = substr($file2[$x], 164, 12);
         if($vtag2 == 1)
         {
            $name_comp = strcmp($name1, $name2);
               if($name_comp != 0)
               {
                  //echo "line".$count."error name" . "<br>";
                  $err_stat = 1;
                  $Error = 1;
                  $err_line = $count;
                  $err_name1 = $name1;
                  $err_name2 = $name2;
	echo "<tr>\n";
	echo "<td>$err_line</td>\n";
	echo "<td>$err_name1</td>\n";
	echo "<td>$err_name2</td>\n";
	echo "</tr>\n";
               }
         }else{
            $addr_comp = strcmp($addr1, $addr2);
            $city_comp = strcmp($city1, $city2);
            $state_comp = strcmp($state1, $state2);
            $zc_comp = strcmp($zc1, $zc2);
            $tf_comp = strcmp($tf1, $tf2);
            $phone_comp = strcmp($phone1, $phone2);
               if($addr_comp != 0)
               {
                  $Error = 1;
                  $err_line = $count;
                  $err_addr1 = $addr1;
                  $err_addr2 = $addr2;
	echo "<tr>\n";
	echo "<td>$err_line</td>\n";
	echo "<td>$err_name1</td>\n";
	echo "<td>$err_name2</td>\n";
	echo "</tr>\n";
               }
               if($city_comp != 0)
               {
                  $Error = 1;
                  $err_line = $count;
                  $err_city1 = $city1;
                  $err_city2 = $city2;
                  echo "Line" . $err_line . " " . "KE City" . " " .  $err_city1 . "<br>";
                  echo  "       QC City" . " " . $err_city2 . "<br>";
               }
               if($state_comp != 0)
               {
                  $Error = 1;
                  $err_line = $count;
                  $err_state1 = $state1;
                  $err_state2 = $state2;
                  echo "Line" . $err_line . " " . "KE State" . " " .  $err_state1 . "<br>";
                  echo  "       QC State" . " " . $err_state2 . "<br>";
               }
               if($zc_comp != 0)
               {
                  $Error = 1;
                  $err_line = $count;
                  $err_zc1 = $zc1;
                  $err_zc2 = $zc2;
	echo "<tr>\n";
	echo "<td>$err_line</td>\n";
	echo "<td>$err_name1</td>\n";
	echo "<td>$err_name2</td>\n";
	echo "</tr>\n";
               }
               if($tf_comp != 0)
               {
                  $Error = 1;
                  $err_line = $count;
                  $err_tf1 = $tf1;
                  $err_tf2 = $tf2;
                  echo "Line" . $err_line . " " . "KE Toll Free Text" . " " .  $err_tf1 . "<br>";
                  echo  "       QC Toll Free Text" . " " . $err_tf2 . "<br>";
               }
               if($phone_comp != 0)
               {
                  $Error = 1;
                  $err_line = $count;
                  $err_phone1 = $phone1;
                  $err_phone2 = $phone2;
	echo "<tr>\n";
	echo "<td>$err_line</td>\n";
	echo "<td>$err_name1</td>\n";
	echo "<td>$err_name2</td>\n";
	echo "</tr>\n";
               }
               
         }
         $count++;
         
      }

   }
echo "</table>";
?>

thanks for the help

i already got it

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
	<title><?php echo $batch[8] ?></title>
</head>

<?php
$kebase = $batch[0];
$qcbase = $batch[1];
	$dir =	$batch[2];
$kedir = $batch[3];
$qcdir = $batch[4] ;
$kefiles = $batch[5];
$qcfiles = $batch[6];
$count_files = $batch[7];
?>
<?php
echo $count_files . " " . "files found" . " " . "in" . " " . $dir . " " . "directory" . "<br>";
?>
<a href="http://localhost/dsvalidator">Home</a>


<pre>
<table border="1" width="0" cellpadding="0" cellspacing="5">
<th>Batch/Line</th>
<th>Field Image</th>
<th>Minor Error</th>
<th>Major Error</th>
<tr>
<?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)){echo 1;}?><?php echo "</td>"; ?>
  <?php echo "<td>";?><?php if(!isset($error)){echo 1;}?><?php echo "</td>"; ?>
  <?php echo "</td></tr>"; ?> 
					<?php	}
						if($type_comp != 0)
							{
								$err_stat = 1;
								$error = TRUE;
								$err_line = $count;
								$err_type1 = $type1;
								$err_type2 = $type2;?>
  <?php echo "<tr><td>"; ?> <?php echo "Line" . " " . $err_line;?><?php echo "</td>"; ?>
  <?php echo "<td>";?><?php echo "KE List Type: " . " " . $err_type1 . "<br>" . "QC List Type: " . " " . $err_type2; ?>
  <?php echo "<td>";?><?php if(!isset($error)){echo 1;}?><?php echo "</td>"; ?>
  <?php echo "<td>";?><?php if(!isset($error)){echo 1;}?><?php echo "</td>"; ?>
  <?php echo "</td></tr>"; ?> 
					<?php	}
						if($name_comp != 0)
							{
								$err_stat = 1;
								$error = TRUE;
								$err_line = $count;
								$err_name1 = $name1;
								$err_name2 = $name2; ?>
  <?php echo "<tr><td>"; ?> <?php echo "Line" . " " . $err_line;?><?php echo "</td>"; ?>
  <?php echo "<td>";?><?php echo "KE Name: " . " " . $err_name1 . "<br>" . "QC Name: " . " " . $err_name2; ?>
  <?php echo "<td>";?><?php if(isset($error)){echo 1;}?><?php echo "</td>"; ?>
  <?php echo "<td>";?><?php if(!isset($error)){echo 1;}?><?php echo "</td>"; ?>
  <?php echo "</td></tr>"; ?>									
					<?php } 
					}else{ 
							$ind_comp = strcmp($ind1, $ind2);
							$addr_comp = strcmp($addr1, $addr2);
							$city_comp = strcmp($city1, $city2);
							$state_comp = strcmp($state1, $state2);
							$zc_comp = strcmp($zc1, $zc2);
							$tf_comp = strcmp($tf1, $tf2);
							$ac_comp = strcmp($ac1, $ac2);
							$phone_comp = strcmp($phone1, $phone2); 
							 if($ind_comp != 0)
								{
									$error = TRUE;
									$err_line = $count;
									$err_ind1 = $ind1;
									$err_ind2 = $ind2;?>
  <?php echo "<tr><td>"; ?> <?php echo "Line" . " " . $err_line;?><?php echo "</td>"; ?>
  <?php echo "<td>";?><?php echo "KE Indent: " . " " . $err_ind1 . "<br>" . "QC Indent: " . " " . $err_ind2; ?>
  <?php echo "<td>";?><?php if(!isset($error)){echo 1;}?><?php echo "</td>"; ?>
  <?php echo "<td>";?><?php if(!isset($error)){echo 1;}?><?php echo "</td>"; ?>
  <?php echo "</td></tr>"; ?>									
						<?php } 
							if($addr_comp != 0)
								{
									$error = TRUE;
									$err_line = $count;
									$err_addr1 = $addr1;
									$err_addr2 = $addr2;?>
  <?php echo "<tr><td>"; ?> <?php echo "Line" . " " . $err_line;?><?php echo "</td>"; ?>
  <?php echo "<td>";?><?php echo "KE Address: " . " " . $err_addr1 . "<br>" . "QC Address: " . " " . $err_addr2; ?>
  <?php echo "<td>";?><?php if(isset($error)){echo 1;}?><?php echo "</td>"; ?>
  <?php echo "<td>";?><?php if(!isset($error)){echo 1;}?><?php echo "</td>"; ?>
  <?php echo "</td></tr>"; ?>									
						<?php } 
								if($city_comp != 0)
								{
									$error = TRUE;
									$err_line = $count;
									$err_city1 = $city1;
									$err_city2 = $city2; ?>
  <?php echo "<tr><td>"; ?> <?php echo "Line" . " " . $err_line;?><?php echo "</td>"; ?>
  <?php echo "<td>";?><?php echo "KE City: " . " " . $err_city1 . "<br>" . "QC City: " . " " . $err_city2; ?>
  <?php echo "<td>";?><?php if(isset($error)){echo 1;}?><?php echo "</td>"; ?>
  <?php echo "<td>";?><?php if(!isset($error)){echo 1;}?><?php echo "</td>"; ?>
  <?php echo "</td></tr>"; ?>									
						<?php	} 
								if($state_comp != 0)
								{
									$error = TRUE;
									$err_line = $count;
									$err_state1 = $state1;
									$err_state2 = $state2; ?>
  <?php echo "<tr><td>"; ?> <?php echo "Line" . " " . $err_line;?><?php echo "</td>"; ?>
  <?php echo "<td>";?><?php echo "KE State: " . " " . $err_state1 . "<br>" . "QC State: " . " " . $err_state2; ?>
  <?php echo "<td>";?><?php if(isset($error)){echo 1;}?><?php echo "</td>"; ?>
  <?php echo "<td>";?><?php if(!isset($error)){echo 1;}?><?php echo "</td>"; ?>
  <?php echo "</td></tr>"; ?>									
						<?php } 
								if($zc_comp != 0)
								{
									$error = TRUE;
									$err_line = $count;
									$err_zc1 = $zc1;
									$err_zc2 = $zc2; ?>
  <?php echo "<tr><td>"; ?> <?php echo "Line" . " " . $err_line;?><?php echo "</td>"; ?>
  <?php echo "<td>";?><?php echo "KE ZipCode: " . " " . $err_zc1 . "<br>" . "QC ZipCode: " . " " . $err_zc2; ?>
  <?php echo "<td>";?><?php if(!isset($error)){echo 1;}?><?php echo "</td>"; ?>
  <?php echo "<td>";?><?php if(isset($error)){echo 1;}?><?php echo "</td>"; ?>
  <?php echo "</td></tr>"; ?>									
						<?php	} 
								if($tf_comp != 0)
								{
									$error = TRUE;
									$err_line = $count;
									$err_tf1 = $tf1;
									$err_tf2 = $tf2; ?>
  <?php echo "<tr><td>"; ?> <?php echo "Line" . " " . $err_line;?><?php echo "</td>"; ?>
  <?php echo "<td>";?><?php echo "KE TollFreeText: " . " " . $err_tf1 . "<br>" . "QC TollFreeText: " . " " . $err_tf2; ?>
  <?php echo "<td>";?><?php if(isset($error)){echo 1;}?><?php echo "</td>"; ?>
  <?php echo "<td>";?><?php if(!isset($error)){echo 1;}?><?php echo "</td>"; ?>
  <?php echo "</td></tr>"; ?>									
						<?php	} 
								if($ac_comp != 0)
								{
									$error = TRUE;
									$err_line = $count;
									$err_ac1 = $ac1;
									$err_ac2 = $ac2; ?>
  <?php echo "<tr><td>"; ?> <?php echo "Line" . " " . $err_line;?><?php echo "</td>"; ?>
  <?php echo "<td>";?><?php echo "KE AreaCode: " . " " . $err_ac1 . "<br>" . "QC AreaCode: " . " " . $err_ac2; ?>
  <?php echo "<td>";?><?php if(isset($error)){echo 1;}?><?php echo "</td>"; ?>
  <?php echo "<td>";?><?php if(!isset($error)){echo 1;}?><?php echo "</td>"; ?>
  <?php echo "</td></tr>"; ?>									
						<?php	} 
								if($phone_comp != 0)
								{
									$error = TRUE;
									$err_line = $count;
									$err_phone1 = $phone1;
									$err_phone2 = $phone2; ?>
  <?php echo "<tr><td>"; ?> <?php echo "Line" . " " . $err_line;?><?php echo "</td>"; ?>
  <?php echo "<td>";?><?php echo "KE PhoneNumber: " . " " . $err_phone1 . "<br>" . "QC PhoneNumber: " . " " . $err_phone2; ?>
  <?php echo "<td>";?><?php if(!isset($error)){echo 1;}?><?php echo "</td>"; ?>
  <?php echo "<td>";?><?php if(isset($error)){echo 1;}?><?php echo "</td>"; ?>
  <?php echo "</td></tr>"; ?>									
						<?php
								} 
							}

			 		$count++;
				} 
			} 
		}
}
?>
</tr>
</table>
</pre>
</head>	
</html>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.