ted_chou12 Posted December 8, 2006 Share Posted December 8, 2006 for example, i have lots text files stored, and I want the php page to include these file with a unique url address of each of them, so when you enter that url, it will include that specific text file within the page. Link to comment https://forums.phpfreaks.com/topic/29902-how-do-you-use-php-functions-to-link-to-a-file-with-the-url-of-the-php/ Share on other sites More sharing options...
ted_chou12 Posted December 8, 2006 Author Share Posted December 8, 2006 anyone has any suggestions? if its not clear enough, dont hesitate to ask me, because i realy need help with this. Link to comment https://forums.phpfreaks.com/topic/29902-how-do-you-use-php-functions-to-link-to-a-file-with-the-url-of-the-php/#findComment-137386 Share on other sites More sharing options...
Orio Posted December 8, 2006 Share Posted December 8, 2006 Can you give an example or something? Because I didnt understand...Orio. Link to comment https://forums.phpfreaks.com/topic/29902-how-do-you-use-php-functions-to-link-to-a-file-with-the-url-of-the-php/#findComment-137389 Share on other sites More sharing options...
ted_chou12 Posted December 8, 2006 Author Share Posted December 8, 2006 okay,lets say i have a text file called "info1.txt" and another one called "info2.txt"I want a php page that includes the file "info1.txt", and I want a id url address for this.however, I also want this php page to include "info2.txt" with another id url adress.id url can be anything like this:http://test.com/page.php?id=info1http://test.com/page.php?id=info2but I just want each of the php page to include each of the two text separatly, so when "http://test.com/page.php?id=info1" is entered in the browser, the php page only shows up "info1.txt", while when "http://test.com/page.php?id=info2" is entered, the php page only shows up the "info2.txt".(Understand now?) Link to comment https://forums.phpfreaks.com/topic/29902-how-do-you-use-php-functions-to-link-to-a-file-with-the-url-of-the-php/#findComment-137394 Share on other sites More sharing options...
Orio Posted December 8, 2006 Share Posted December 8, 2006 Almost ;)So you have a page that includes files (single files only) and you want it to be able to include more than one file?Orio. Link to comment https://forums.phpfreaks.com/topic/29902-how-do-you-use-php-functions-to-link-to-a-file-with-the-url-of-the-php/#findComment-137397 Share on other sites More sharing options...
ted_chou12 Posted December 8, 2006 Author Share Posted December 8, 2006 yeap, kindof, but one file at a time with a unique url :D Link to comment https://forums.phpfreaks.com/topic/29902-how-do-you-use-php-functions-to-link-to-a-file-with-the-url-of-the-php/#findComment-137398 Share on other sites More sharing options...
ted_chou12 Posted December 8, 2006 Author Share Posted December 8, 2006 have you got any other ideas? Link to comment https://forums.phpfreaks.com/topic/29902-how-do-you-use-php-functions-to-link-to-a-file-with-the-url-of-the-php/#findComment-137403 Share on other sites More sharing options...
Orio Posted December 8, 2006 Share Posted December 8, 2006 You can make id to be like this (example):?id=file1|file2|file3And then the script will do this:[code]<?php$files = explode("|",$_GET['id']);foreach ($files as $include) include($include.".txt");?>[/code]Orio. Link to comment https://forums.phpfreaks.com/topic/29902-how-do-you-use-php-functions-to-link-to-a-file-with-the-url-of-the-php/#findComment-137416 Share on other sites More sharing options...
papaface Posted December 8, 2006 Share Posted December 8, 2006 [code]<?php$file = $_GET["id"] . ".txt";$open = fopen($file, "r");print "<pre>";print (file_get_contents($file));print "</pre>";fclose($open);?>[/code]That will do what you want.example. page.php?id=helloWill produce text file: hello.txt Link to comment https://forums.phpfreaks.com/topic/29902-how-do-you-use-php-functions-to-link-to-a-file-with-the-url-of-the-php/#findComment-137419 Share on other sites More sharing options...
ted_chou12 Posted December 8, 2006 Author Share Posted December 8, 2006 thankyou! :D Link to comment https://forums.phpfreaks.com/topic/29902-how-do-you-use-php-functions-to-link-to-a-file-with-the-url-of-the-php/#findComment-137423 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.