Q:

How to create parallel output from content from many pages?

I need your some help...
How to create parallel output from many pages in one pages, see examples:
I store all data in plain text e.g.
old-book-version.txt
1:1 dadidedodu....
1:2 cacecocuci....
2:1 papopupepi....
2:2 lalilolule....
2:3 and more......

mid-book-version.txt
1:1 dedadodedu....
1:2 cacicecuca....
2:1 popapepupi....
2:2 lalilolule....
2:3 and more......

new-book-version.txt
1:1 dudadidode....
1:2 cucacoceco....
2:1 pepipupapo....
2:2 lalilolule....
2:3 and more......

and i create php file to show them to the web broser for each file txt
like: 
old-book-version.php to show old-book-version.txt, 
mid-book-version.php to show mid-book-version.txt,
new-book-version.php to show new-book-version.txt.

the url browser look like: 
http://localhost/book/old-book-version.php/old-book-version.txt/2/1 output: 2:1 papopupepi.... 
http://localhost/book/mid-book-version.php/mid-book-version.txt/2/1 output: 2:1 popapepupi....
http://localhost/book/new-book-version.php/new-book-version.txt/2/1 output: 2:1 pepipupapo....

(.../2/1 mean chapter 2 verse 1)
all running well but i also want to create them parallel in one page as comparison with drop down command button option, that mean i give an option to the visitor to compare each version as parallel in one page. after i search on the google i found the example

Regards,

A:

your select can have an onchange
<select onchange="document.location=this.options[this.selectedIndex].value">
<option value="page1.php">Page #1</option>
<option value="page2.php">Page #2</option>
</select>
To concatenate them all, you can do
$files = glob(dirname(__FILE__) . '/articles/*.txt');
foreach ($files as $f) {
  echo "<p>File $f:</p><pre>";
  readfile($f);
  echo '</pre>';
}

that form with the dropdowns lets you select 2 different sources, so the php script will control the display based on the requested sources. you can let the user hit "submit" to submit the form or you can automatically do it in the onchange event.
First: <select name="source[]"><option value="s1">Source #1</option></select>

Second: <select name="source[]"><option value="s1">Source #1</option></select>

for ($i = 0; $i < count($_REQUEST['source']); ++$i) {
  printText($_REQUEST['source'][$i];
}
function printText($source)
{
  $file = dirname(FILE) . "/texts/$source/something.txt";
  $text = file_get_contents($file);
  echo "$text";
}

