0

I have looked at all the posts I could find but they don't quite to seem to do it!

Any help appreciated.

Have inserted relevant php code here:

Previously having done the search and placed the number of matches in the variable $num_rows I then turn the relevant data into variables $displayurl and $displaytitle, then place them in a table cell. I want to display the data in $displayurl as a hyperlink.

$i = 0;

while ($i < $num_rows) {
$displayurl=mysql_result($result,$i,"url");
$displaytitle = mysql_result($result, $i, "pagetitle");
echo "<tr>";    
echo "<td align = left>"  .$displayurl. " </td>"; 
echo "<td align = left> " .$displaytitle. " </td>";
echo "</tr>";

$i++;
}
2

4 Answers 4

1

echo "<td align = left><a href='" .$displayurl. "'>link1</a></td>";

Sign up to request clarification or add additional context in comments.

Comments

0

surround it by <A> tag

$i = 0;

while ($i < $num_rows) {
$displayurl=mysql_result($result,$i,"url");
$displaytitle = mysql_result($result, $i, "pagetitle");
echo "<tr>";    
echo "<td align = left><a href='"  .$displayurl. "'>link1</a> </td>"; 
echo "<td align = left> " .$displaytitle. " </td>";
echo "</tr>";

$i++;
}

Comments

0

You can also do it this way

echo "<td align = left><a href='$displayurl'>Click here</a></td>"; 

OR

echo "<td align = left><a href=\"$displayurl\">Click here</a></td>"; 

Comments

0

In the HTML, an anchor tag or link is written as <a href="url goes here">Text that gets the underline</a>

<?php

$i = 0;

while ($i < $num_rows) {
    $displayurl   = mysql_result($result, $i, 'url');
    $displaytitle = mysql_result($result, $i, 'pagetitle');
    echo '<tr>';
    echo '<td align="left"> <a href="' . $displayurl . '">'  . $displayurl . '</a> </td>';
    echo '<td align="left"> ' . $displaytitle . ' </td>';
    echo '</tr>';

    $i++;
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.