Hi,

I have a form where users enter information. One field is a text box where the user enters a url. It is stored as text format in my table. I want it to appear as a hypertext link when the user view the information.

This is the code to assign that record in the table to a variable:
$addInfo = $row_Project['ProjectLink'];

This is the code where i want it to print the text stored as a link:
<tr>
<td class="style1" width="32%" ><div align="left" class="style8">Project URL</div></td>
<td scope="row" width="78%"><div align="left" class="style12"><?php if(isset($addInfo)) {echo ($addInfo);} ?></div></td>
</tr>

i'm not sure where to place the <a href> tags. everything i've tried so far has given an error.

Please help...

    Are you familiar with the simple HTML syntax?

    <a href="http://url">url text</a>

    If so, show us what you tried to add to the PHP code.

      Hey this is what i have right now. I know it seems stupid but i'm trying anything right now...

      <?php if(isset($addInfo)) <a href="{echo($addInfo);}"$addInfo</a> ?>

      The $addInfo variable is stored in the database table as a text field. I want it to appear as a hyperlink when the user views the information.

        <?php if($addInfo)echo "<a href=\"$addInfo\">$addInfo</a>";?>

          I tried that but once i add target="_blank" to the <a> element, the page to view in order to click on the link shows up with a page cannot be displayed error.

            You have to write the adress with "http://" first, to show the browser that it is an external page. Meaning "www.hotmail.com" becomes "http://www.hotmail.com"

              ok thanks. now i have two other questions:

              1. How do i get http:// as a default value in the text box so the user will just enter the rest of the url.

              2. when i use http://www.hotmail.com it opens the page in the same browser window. How do i get it to open in a new window. I tried target="_blank" but when i do that my original page doesn't come up period.

                1. Using the VALUE attribute, i.e.

                  <input type="text" name="foo" value="bar" />

                  You might, however, want to check that the URL they submit begins with 'http://' (or possibly even 'https://') and, if not, prepend it to the string.

                2. Again, show us the code you tried to implement that caused the error.

                  Write a Reply...