views:

72

answers:

2

Hi all, 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 http://www.gospelhall.org/images/stories/bible-parallel.gif

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"; }

jspcal
ok thank you first, i know you mean, but this just select one only, that i need is appear all in one page as parallel as comparison
jones
try concatenating them
jspcal
Hello sir, after search the examples picture from Google i found that i mean... see the picture above, thx
jones
Your code error in line: printText($_REQUEST['source'][$i]; comments error: Parse error: syntax error, unexpected ';' in C:\xampp\htdocs\...\index.php on line 792
jones
that wasn't something i pasted, but as for the error you're getting, are you missing a close paren somewhere? e.g.: printText($_REQUEST['source'][$i]);
jspcal
i moved your code as independent file but error not change, i think that tips you given to me will display all values in a page.. ("/texts/$source/something.txt";).
jones
A: 

I have another idea:

$path["URI_prefix"]="http://localhost/books/";
$path["script_suffix"] = "";//as old-book-version.php, mid-book-version.php, new-book-version.php
$path["book"]=""; //as old-book-version.txt,  mid-book-version.txt, new-book-version.txt

First: <select name="parallel1"><option value="" . $path["URI_prefix"] . $path["script_suffix"] . $path["book"] . "/" . $path["chapter"] . "/" . $path["verse"]">Option1 #1</option></select>
Second: <select name="parallel2"><option value="" . $path["URI_prefix"] . $path["script_suffix"] . $path["book"] . "/" . $path["chapter"] . "/" . $path["verse"]">Option #2</option></select>

But how to implementing all of them in one php page?

jones