Jump to content


Photo

How to make links with .txt file results


  • Please log in to reply
1 reply to this topic

#1 ginocote

ginocote
  • Members
  • PipPip
  • Member
  • 13 posts

Posted 19 July 2006 - 06:45 PM

Hi,

I got this script and it's working well.
for opening a .txt file and open it in a php webpage.

<? 
$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>"; 
?>

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 files

Computer
laptop
website hosting
ect....

each word or phrase have to become a query link.
<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>

i need to place a .gif image before each link, like a little arrow.

This is for my website
http://www.composantinformatique.com

This is my results
http://www.composant...mtext1ligne.php
The .txt file
http://www.composant...ripts/links.txt


Than you to help

#2 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 19 July 2006 - 09:23 PM

Change the instances of echo "<td>$contents[$a]</td>"; to this:

echo "<td><img src='arrow.gif'><a href='/search?q=".$contents[$a]. "'>". $contents[$a]. "</a></td>";

Legend has it that reading the manual never killed anyone.
My site




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users