ErrorLINE1CHAR1
Programmer
Hello again people of TT...
I'm having an issue, I have been losing sleep for the past couple of days between reading hundreds of forums,
and trying what seems like thousands of different attempts to change the displayed file when you click on a link.
It may sound simple but its actually complex as I am not changing the page I'am simply trying to $_POST the value
of an array to a variable. let me demonstrate..(I hope i don't confuse people :/ )
So there is the basic of it, (I assure you any variables ^up^ there that are not there are in the actual source.)
But my problem is that i cant figure out how to change the point in the array based on the name $file in the link..
the only thing it does right now is load the page and display the contents of "test.txt".
(test.txt is in the directory also the last point of the array.)
I have tried to $_POST['link']; but I don't think that that is possible to get that value from an echo..
Im not sure how i could provide a none echo'd link with the value of the foreach though..?
The onclick event works and self submits but only reloads test.txt;
The onsubmit I have tried a few different ways including removing it, putting it in
a function that does the same thing then putting it in the onclick event.. still nothing..
I'm not even sure if what i am doing is possible it could be with JavaScript but i know just about 0 of that..
Maybe I'm going about this the wrong way but I have zero help from any of my coding buddies because they are all
busy on other parts of our App..(the easy stuff)
Oh and before I forget there is ZERO errors.
And please if you have a question DO ASK! I'm well aware that this is probably the most confusing post you have ever seen..
(Its hard to be a genius that thinks a million miles a second, and try to put all though process into a single query... )
I will link to a live demo but only via PM as it is NOT open for the public..
Thanks for all your help!!
Devon
Intel Corp. (HF)
I'm having an issue, I have been losing sleep for the past couple of days between reading hundreds of forums,
and trying what seems like thousands of different attempts to change the displayed file when you click on a link.
It may sound simple but its actually complex as I am not changing the page I'am simply trying to $_POST the value
of an array to a variable. let me demonstrate..(I hope i don't confuse people :/ )
Code:
<?php
$ptf = "path/to/file/";
$lines = file($ptf);
$files = read_folder_directory ("path");
function chngFile() {
$ptf .= $file;
}
//The function to create the array from the directory.
function read_folder_directory($dir = "./path/path") {
$listDir = array();
if($handler = opendir($dir)) {
while (($sub = readdir($handler)) !== FALSE) {
if ($sub != "." && $sub != ".." && $sub != "Thumb.db" && $sub != "Thumbs.db") {
if(is_file($dir."/".$sub)) {
$listDir[] = $sub;
} elseif(is_dir($dir."/".$sub)){
$listDir[$sub] = ReadFolderDirectory($dir."/".$sub);
}
}
}
closedir($handler);
}
return $listDir;
}
//List each file as a link.
foreach ($files as $file) {
echo "<a href='' name='link' onclick='document.forms('postfrm').submit(); return false;' onsubmit='chngFile();' >" . $file . "</a>";
}
//Read each line of the chosen $file, and output it.
foreach($lines as $line_num => $line) {
echo "htmlspecialchars($line)";
}
?>
So there is the basic of it, (I assure you any variables ^up^ there that are not there are in the actual source.)
But my problem is that i cant figure out how to change the point in the array based on the name $file in the link..
the only thing it does right now is load the page and display the contents of "test.txt".
(test.txt is in the directory also the last point of the array.)
I have tried to $_POST['link']; but I don't think that that is possible to get that value from an echo..
Im not sure how i could provide a none echo'd link with the value of the foreach though..?
The onclick event works and self submits but only reloads test.txt;
The onsubmit I have tried a few different ways including removing it, putting it in
a function that does the same thing then putting it in the onclick event.. still nothing..
I'm not even sure if what i am doing is possible it could be with JavaScript but i know just about 0 of that..
Maybe I'm going about this the wrong way but I have zero help from any of my coding buddies because they are all
busy on other parts of our App..(the easy stuff)
Oh and before I forget there is ZERO errors.
And please if you have a question DO ASK! I'm well aware that this is probably the most confusing post you have ever seen..
(Its hard to be a genius that thinks a million miles a second, and try to put all though process into a single query... )
I will link to a live demo but only via PM as it is NOT open for the public..
Thanks for all your help!!
Devon
Intel Corp. (HF)