Jump to content

Way to show multiple txt files ....................


Cooleyvol

Recommended Posts

Ok, so I have a site with a page that I want to show multiple .txt files inside it based on the button clicked at the top of the page.

 

I know how to include a txt file in that page, but I don't know how to make the txt file shown on the page chosen by the user selecting the web nav button of his choice.

 

I know I could create multiple pages with the nav area at the top and each txt file on a separate page, but I'd like to create just one page and have only the middle content (text file) change based on the button selected.

 

The nav area is at the upper portion; the txt file would display in a table below the nav area.

 

Is there a way to do this?

 

Here's a link to the page:

http://iff.totalsportsworld.net/apexnav.php

 

The buttons in the blue/yellow area would control which text file shows up in the area just below it (white b/g).

 

Mark Cooley

cooleyatcharterdotnet

Link to comment
https://forums.phpfreaks.com/topic/83657-way-to-show-multiple-txt-files/
Share on other sites

I see no reason why ajax would be a suggested solution.

 

All you simply need do is make you nav links pass a variable via get, then use this to display the correct file. eg;

 

<ul>
  <li><a href="?f=foo">foo</a></li>
  <li><a href="?f=bar">bar</a></li>
  <li><a href="?f=bob">bob</a></li>
</ul>
<?php

  if (isset($_GET['f'])) {
    if (file_exists($_GET['f'] . '.txt')) {
      echo file_get_contents($_GET['f'] . '.txt');
    }
  }

?>

I see no reason why ajax would be a suggested solution.

 

All you simply need do is make you nav links pass a variable via get, then use this to display the correct file. eg;

 

<ul>
  <li><a href="?f=foo">foo</a></li>
  <li><a href="?f=bar">bar</a></li>
  <li><a href="?f=bob">bob</a></li>
</ul>
<?php

  if (isset($_GET['f'])) {
    if (file_exists($_GET['f'] . '.txt')) {
      echo file_get_contents($_GET['f'] . '.txt');
    }
  }

?>

 

How would that be worked given the image in the supplied link to the page? That image will be hotspotted and those will be linked areas to the different txt files.

I see no reason why ajax would be a suggested solution.

 

All you simply need do is make you nav links pass a variable via get, then use this to display the correct file. eg;

 

<ul>
  <li><a href="?f=foo">foo</a></li>
  <li><a href="?f=bar">bar</a></li>
  <li><a href="?f=bob">bob</a></li>
</ul>
<?php

  if (isset($_GET['f'])) {
    if (file_exists($_GET['f'] . '.txt')) {
      echo file_get_contents($_GET['f'] . '.txt');
    }
  }

?>

Could I link the hotspots using just this code:

<a href="?f=foo"></a>

Archived

This topic is now archived and is closed to further replies.

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