Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3491026
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T11:35:14+00:00 2026-05-18T11:35:14+00:00

So I am reading from a text file which has product information I have

  • 0

So I am reading from a text file which has product information I have four tables for the different computers computer 1 shows table 1 which is read from file1, computer 2 shows table 2 which is read from file 2, etc etc. BUT for some reason computer 3&4 show information from table 2 and also 3&4 i havent got a clue whats going on hope my code can give a better view.

Table 1

    <?php
    error_reporting(E_ALL ^ E_NOTICE);
    $row = 0;
    $sortby ='';
    $sortkey='';

echo '<h1><span class="sortby"></span></h1>
<table cellspacing="5" summary="QA Tables">
<tr>
<th>Products</th>
<th>Types</th>
<th>Keys</th>
<th>Date & Time Added</th>
</tr>';

$fp = fopen('key_QA_N1.txt','r');
if (!$fp) {echo 'ERROR: Unable to open file.</table></body></html>'; exit;}

while (!feof($fp)) {
    $line = fgets($fp,1024); //use 2048 if very long lines
    $row++;
    list ($products,$types, $keys, $date) = explode('|', $line);
    if ($sortby == 'Products') $sortkey = strtolower($products);
    if ($sortby == 'Types') $sortkey = strtolower($types);
    if ($sortby == 'Keys') $sortkey = strtolower($keys);
    if ($sortby == 'Date & Time Added') $sortkey = strtolower($date);
       $col[$row] = array($sortkey, $products, $types, $keys, $date);
}

fclose($fp);

$arrays = count($col) - 1;

$loop = 0;
while ($loop < $arrays) {
    $loop++;
    echo '
<tr>
<td>'.$col[$loop][1].'</td>
<td>'.$col[$loop][2].'</td>
<td>'.$col[$loop][3].'</td>
<td>'.$col[$loop][4].'</td>
</tr>';
}

echo '
</table>
 '
?>

Table 2

<?php
    error_reporting(E_ALL ^ E_NOTICE);
    $row = 0;
    $sortby ='';
    $sortkey='';

echo '<h1><span class="sortby"></span></h1>
<table cellspacing="5" summary="QA Tables">
<tr>
<th>Products</th>
<th>Types</th>
<th>Keys</th>
<th>Date & Time Added</th>
</tr>';

$fp = fopen('key_QA_N2.txt','r');
if (!$fp) {echo 'ERROR: Unable to open file.</table></body></html>'; exit;}

while (!feof($fp)) {
    $line = fgets($fp,1024); //use 2048 if very long lines
    $row++;
    list ($products,$types, $keys, $date) = explode('|', $line);
    if ($sortby == 'Products') $sortkey = strtolower($products);
    if ($sortby == 'Types') $sortkey = strtolower($types);
    if ($sortby == 'Keys') $sortkey = strtolower($keys);
    if ($sortby == 'Date & Time Added') $sortkey = strtolower($date);
      $col[$row] = array($sortkey, $products, $types, $keys, $date);
}

fclose($fp);

$arrays = count($col) - 1;

$loop = 0;
while ($loop < $arrays) {
    $loop++;
    echo '
<tr>
<td>'.$col[$loop][1].'</td>
<td>'.$col[$loop][2].'</td>
<td>'.$col[$loop][3].'</td>
<td>'.$col[$loop][4].'</td>
</tr>';
}

echo '
</table>
 '
?>

Table 3

<?php
    error_reporting(E_ALL ^ E_NOTICE);
    $row = 0;
    $sortby ='';
    $sortkey='';

echo '<h1><span class="sortby"></span></h1>
<table cellspacing="5" summary="QA Tables">
<tr>
<th>Products</th>
<th>Types</th>
<th>Keys</th>
<th>Date & Time Added</th>
</tr>';

$fp = fopen('key_QA_N3.txt','r');
if (!$fp) {echo 'ERROR: Unable to open file.</table></body></html>'; exit;}

while (!feof($fp)) {
    $line1 = fgets($fp,1024); //use 2048 if very long lines
    $row++;
    list ($products1,$types1, $keys1, $date1) = explode('|', $line1);
    if ($sortby == 'Products') $sortkey = strtolower($products1);
    if ($sortby == 'Types') $sortkey = strtolower($types1);
    if ($sortby == 'Keys') $sortkey = strtolower($keys1);
    if ($sortby == 'Date & Time Added') $sortkey = strtolower($date1);
     $col[$row] = array($sortkey, $products1, $types1, $keys1, $date1);
}

fclose($fp);

$arrays = count($col) - 1;

$loop = 0;
while ($loop < $arrays) {
    $loop++;
    echo '
<tr>
<td>'.$col[$loop][1].'</td>
<td>'.$col[$loop][2].'</td>
<td>'.$col[$loop][3].'</td>
<td>'.$col[$loop][4].'</td>
</tr>';
}

echo '
</table>
 '
?>

Table 4

<?php
    error_reporting(E_ALL ^ E_NOTICE);
    $row = 0;
    $sortby ='';
    $sortkey='';

echo '<h1><span class="sortby"></span></h1>
<table cellspacing="5" summary="QA Tables">
<tr>
<th>Products</th>
<th>Types</th>
<th>Keys</th>
<th>Date & Time Added</th>
</tr>';

$fp = fopen('key_QA_N4.txt','r');
if (!$fp) {echo 'ERROR: Unable to open file.</table></body></html>'; exit;}

while (!feof($fp)) {
    $line2 = fgets($fp,1024); //use 2048 if very long lines
    $row++;
    list ($products2,$types2, $keys2, $date2) = explode('|', $line2);
    if ($sortby == 'Products') $sortkey = strtolower($products2);
    if ($sortby == 'Types') $sortkey = strtolower($types2);
    if ($sortby == 'Keys') $sortkey = strtolower($keys2);
    if ($sortby == 'Date & Time Added') $sortkey = strtolower($date2);
       $col[$row] = array($sortkey, $products2, $types2, $keys2, $date2);
}

fclose($fp);

$arrays = count($col) - 1;

$loop = 0;
while ($loop < $arrays) {
    $loop++;
    echo '
<tr>
<td>'.$col[$loop][1].'</td>
<td>'.$col[$loop][2].'</td>
<td>'.$col[$loop][3].'</td>
<td>'.$col[$loop][4].'</td>
</tr>';
}

echo '
</table>
 '
?>

Kind regards E.P

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T11:35:15+00:00Added an answer on May 18, 2026 at 11:35 am

    Try adding $col = array(); at the beginning of each section.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was reading JavaScript: The Good Parts and the author mentions that JavaScript is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.