Hello!
There is the following script:
<?php $handle = @fopen('base.txt', 'r') or die('Не удалось открыть файл'); // открываем файл /* читаем файл построчно*/ while(!feof($handle)){ $read[] = fgets($handle); } /*распечатаем массив echo '<pre>'; print_r($read); echo '</pre>'; */ /*разбираем строки на элементы*/ $i = 0; foreach($read as $item){ if(!empty($item)){ $data[] = explode('//', $item); echo '<div class="question">' .$data[$i][0]. '</div>'; echo '<div class="answer">' .$data[$i][1]. '</div>'; $i++; } } fclose($handle); // закрываем файл ?>
The script is designed to organize the FAQ section on the site. He lists the question-answer list, taking data from a text file (base.txt). However, it is very suitable for me to create an address and telephone directory. There is only one drawback, I would like the data on organizations to be displayed not only by a common list, but also for each org-tion in a separate page, that is, as is customary in modern Internet directories (yell.ru, for example).
Therefore, help make sure that in this script, for example, the string
echo '<div class="question">'.$data[$i][0].'</div>';
where the question is displayed, would also be a link to the file, where in a separate window the corresponding question-answer from one database would be displayed. It will be very convenient. I hope I clearly explained what I want. I would greatly appreciate such help.