Forum Moderators: coopster

Message Too Old, No Replies

Hyperlink in Search Results

         

fishy03

1:24 am on Jul 15, 2009 (gmt 0)

10+ Year Member



I'm new to php, and have gotten stuck. After a lot of trial and error, I got my search to work.

The part of my code i'm working with is:

if (mysql_num_rows($searchResult) < 1) {
$error[] = "The search term {$searchTerms} yielded no results.";
}else {
$results = array(); // the result array
$i = 1;
while ($row = mysql_fetch_assoc($searchResult)) {
$results[] = "{$row['id']} - {$row['titletext']}<br />";
$i++;
}

What I am trying to do is hyperlink each ID to a page calling the ID. What is that correct syntax so that {$row['id']} would be hyperlinked to the page?

penders

10:01 am on Jul 15, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



You need to construct an HTML anchor and echo that to your page. Of the form:
echo '<a href="index.php?id='.$row['id'].'">'.$row['titletext'].'</a>';