Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Mal

macrumors 603
Original poster
Jan 6, 2002
6,253
30
Orlando
I am creating a simple search engine on my site, and I'd like to streamline the display, since it's kinda ugly now. I was working from a template given to me by my instructor, and currently it simply says "Your query is found in File #" with the words "File #" being the link. I'd rather have it say something like "Your query is found in the following files:" then list the files below it.

Here's the PHP code used right now:
Code:
print("<p>Your query is found in <a href=".$all_pages[$i].">"."File ".$i."</a>");

Basically what I would need to do is use the value of $all_pages[$i] instead of simply using the number $i. How would I recall the value of that element in the array? I'm fairly new to PHP, and I can't find it in any of the searches I've used so far.

jW
 
Code:
print("<p>Your query is found in <a href=".$all_pages[$i].">"."File ".$i."</a>");

You'd do it the same way that the link references the file.

PHP:
<?php
print("<p>Your query is found in <a href=\"".$all_pages[$i]."\">"."File ".$all_pages[$i]."</a>");
?>

$all_pages is the array, and $i is the element. So if you want the value in that element of the array, all you need to do is print $all_pages[$i].
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.