ginocote Posted July 19, 2006 Share Posted July 19, 2006 Hi,I got this script and it's working well.for opening a .txt file and open it in a php webpage.[code]<? $filename = "some_text_file.txt"; $handle = fopen($filename, "r"); $contents = fread($handle, filesize($filename)); fclose($handle); $contents=explode("\n", $contents); echo "<table><tr>"; $i=-1; $a=-1; while($a < count($contents)){ $i++; $a++; if($i==3){ echo "</tr><tr>"; echo "<td>$contents[$a]</td>"; $i=0; }else{ echo "<td>$contents[$a]</td>"; } } echo "</tr></table>"; ?> [/code]I want to modify it.can someone help me with this?How can i do to make each word or phrase become a link?For example i have these keywords in my text filesComputerlaptopwebsite hostingect....each word or phrase have to become a query link.[code]<a href="http://www.mysite.com/search?q=computer">Computer</a><a href="http://www.mysite.com/search?q=Laptop">Laptop</a><a href="http://www.mysite.com/search?q=Website Hosting">Website+Hosting</a> [/code]i need to place a .gif image before each link, like a little arrow.This is for my websitehttp://www.composantinformatique.comThis is my resultshttp://www.composantinformatique.com/scripts/menufromtext1ligne.phpThe .txt file http://www.composantinformatique.com/scripts/links.txtThan you to help Link to comment https://forums.phpfreaks.com/topic/15064-how-to-make-links-with-txt-file-results/ Share on other sites More sharing options...
AndyB Posted July 19, 2006 Share Posted July 19, 2006 Change the instances of echo "<td>$contents[$a]</td>"; to this:[code]echo "<td><img src='arrow.gif'><a href='/search?q=".$contents[$a]. "'>". $contents[$a]. "</a></td>"; [/code] Link to comment https://forums.phpfreaks.com/topic/15064-how-to-make-links-with-txt-file-results/#findComment-60662 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.