Jump to content

Help request


scottish2

Recommended Posts

Hi Everyone

 

First off I don't know PHP except the includes statement which I use regularly to make the site a little easier to update.

 

But anyways am having an issue. I am trying to make a standard template page. On a prior site I had it set up this way with the code I will post below and it worked for me but I have tried to implement it on this site and am not having any luck.

 

Few things on the code below. It was designed for another site. So what I need is as follows. The home page should bring up the default index.txt file. That has the home page info on it. Second the code below has a table in the coding as I required a table on my site so that is in the code but for this site don't need the table. There is also one image in the code. That too is no longer required.

 

I will just leave these in place that way you can see the code I am working with so you can hopefully correct it to work for me as I am going nuts trying to get this to work.

 

Also somewhere in the coding it seems maybe there is an open link tag as I did get this to work a little bit but for some reason when it was the TXT file information was also being made to be a link even though the txt file for time being only contains basic text no coding what so ever.

 

Now what I need is as follows. Default home page TXT file loaded when home page loads. But the link below is what I was using for my site and when this was clicked it would load the TXT file for that page so the example link below would open up a members page that was associated with my message board I was using.

 

<a href="members.php?categories_file=Members">Forum Members Websites</a>

 

that link would bring up file members.txt which was stored in the text folder

 

Below is the code that in both cases was and is placed in the main window of the table I am using for layout. Last time this all worked perfectly but this time not sure why it refuses to load the page like it use to.

 

Can anyways sort this code so it works fine for me.

 

Thanks!!

Dave

 

<?php


if ($_GET['categories_file'])
$fp = fopen("text/$categories_file.txt", "r")
or die("Could not open $categories_file.");
while (!feof($fp)) {
$line = fgets($fp, 512);
$categories[] = $line; }
asort($categories)
or die("Could not sort array.");
$table_column_counter = 0;
echo "<table border='0' cellpadding='0' cellspacing='0' width='90%'>";
foreach ($categories as $item) {
if ($table_column_counter == 0) {
echo "<tr>\r\n"; }

$link = explode(",", $item);
echo "<td><img src='images/green.gif' width='13' height='13'><a 
href='$link[1]' target='_blank'>".$link[0]."</a></td>";

if ($table_column_counter == 2) {
echo "</tr>\r\n"; }
$table_column_counter = $table_column_counter + 1;
if ( $table_column_counter >= 2 ) {
$table_column_counter = 0; } }
?>

Link to comment
Share on other sites

So, to summarize your ten paragraphs, you want to grab a text file based on the contents of $_GET['categories_file']? What part isn't working precisely? What does your page output? Setting a default is as simple as

 

<?php
$categories_file = (isset($_GET['categories_file'])) ? $_GET['categories_file'] : "index";
if (!empty($categories_file)
// etc

Link to comment
Share on other sites

So, to summarize your ten paragraphs, you want to grab a text file based on the contents of $_GET['categories_file']? What part isn't working precisely? What does your page output? Setting a default is as simple as

 

<?php
$categories_file = (isset($_GET['categories_file'])) ? $_GET['categories_file'] : "index";
if (!empty($categories_file)
// etc

 

Yes basically the category is the txt files file name.

 

so if this is the link

 

<a href="members.php?categories_file=[color=red]the moon is blue[/color]">Forum Members Websites</a>

 

it will pull up a file titled the moon is blue.txt

 

and each link on the site would pull up a different page in the same manor.

 

And like I said sorry don't know PHP someone in another group helped me with this ages ago when I had my site.

Link to comment
Share on other sites

Bare in mind this page is NOT working but give you an idea. This was using the code I posted above in the first post

 

http://namgyalrapper.com/test/TYC/test.php

 

The test link on left side should pull up test.txt but as you can see first it is NOT pulling up the default index.txt file for the home page and second when you click test it is not pulling up test.txt either. At one point I did have it partly working where the link would bring up the file but then it went weird and stopped plus I never got plain text in the main box for some reason the text in the main box when loaded would always be a link like somewhere there was an unclosed link tag but unsure why as never had that issue prior when using the code above.

Link to comment
Share on other sites

Opps

 

Sorry just came to check any replies and noticed the forums code didn't get converted in the code box so am reposting the link as it is without the forums code. Sorry can't edit as been too long so edit is not possible. Below is what the links I was using look like read above (2 posts) for example

 

<a href="members.php?categories_file=the moon is blue">Forum Members Websites</a>

Link to comment
Share on other sites

Opps

 

Sorry just came to check any replies and noticed the forums code didn't get converted in the code box so am reposting the link as it is without the forums code. Sorry can't edit as been too long so edit is not possible. Below is what the links I was using look like read above (2 posts) for example

 

<a href="members.php?categories_file=the moon is blue">Forum Members Websites</a>

 

It might be due to the spaces in the file name. Try replacing them with dashes.

Link to comment
Share on other sites

No spacing isn't the issue cause on the test page the file name is simply test.txt so the link also is just test. And it still won't work.

 

Like I said I had this working on my old site even with spaces in the link and it worked fine just not sure why it refuses to work on this site I am helping to redesign.

 

Just trying to set it up to be idiot proof so they can easily update the site as the site changes hands some times and if all they have to do is program the content and can leave the rest of the page alone that helps alot when changing hands cause they don't really have to learn the site other then the layout and basics of it and such.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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