Hi,

Using dreamweaver / webassist extension / Apache 2.0.59, MySQL 5.0.41, PHP 5.2.6 on a mac:

After selecting my criteria on my search page I go to a result page where I display several information from my database. I have 10 results per page and each result has field displaying the name of a website (text)

New to php mysql, I don't know how to add a hyperlink to a text from my database. In the code below on the line where I have :
<div class="WADAResultPrice"><?php echo $row_WADAcompanies["Website"]; ?></div> I would like to display the name of a website in my result page (which I manage to have) but I would also like to have the possibility to click on the name to go to the website - that is where I am stuck...

I already looked at several forum and tried the solution given which was:

<div class="WADAResultPrice"><?php echo <a href=$row_WADAcompanies["Website"]> $row_WADAcompanies["Website"]</a>; ?></div>

but the only thing I get is a blank page instead of my result page.

Anybody would know how to do that?

<table id="WADAResultsTable" border="0" cellpadding="0" cellspacing="0">
            <?php do { ?>
              <tr>
                <td class="WADAResultsEntry"><div class="WADAResultThumbArea"><img class="WADAResultThumb" border="0" src="WA_DataAssist/images/img_160x110.gif" alt="Image Name" /></div>
                  <div class="WADAResultInfoArea">
                    <div class="WADAResultTitle"><?php echo $row_WADAcompanies["Nom"]; ?></div>
                    <div class="WADAResultDescription"><?php echo $row_WADAcompanies["Activite"]; ?></div>
                    <div class="WADAResultCommerceArea">
                      <div class="WADAResultCommerceButton">[ button ]</div>
                     <div class="WADAResultPrice"><?php echo $row_WADAcompanies["Website"]; ?></div>
                      <div class="WADAClearRight"></div>
                      </div>
                    </div></td>
                </tr>
              <?php } while ($row_WADAcompanies = mysql_fetch_assoc($WADAcompanies)); ?>
            </table>

Thanks

try

<div class="WADAResultPrice"><?php echo '<a href='.$row_WADAcompanies["Website"].'>'.$row_WADAcompanies["Website"].'</a>'; ?></div>

the html in the php echo statment still has to be quoted as text, the php arrays variables dont

wrong, what looked like wrong quotes, wasn't, shouldn't have edit the last post

<div class="WADAResultPrice"><?php echo "<a href=\"".$row_WADAcompanies["Website"]."\">".$row_WADAcompanies["Website"]."</a>"; ?></div>

Thanks for the help!

I am a step closer... The text is now showing as an hyperlink so that's in the good direction. Never manged to get this far ;-)

Now in my results I have www.company-A.com with a functional hyperlink but the hyperlink direct me to :

http://localhost:8888/my-website/www.company-A.com
which gives me a "Not Found" message of course.

What would be the next step to be redirected to www.company-A.com directly?

Thanks

You need to mention http:// in your hyperlinks. See this for example.

<?php
echo "<a href='www.google.com'>Click here </a><br />";
echo "<a href='http://www.google.com'>Click here too</a>";
?>

sorry bloke,
you said you had the website in your database,
I read that to mean you had the full URI stored in the database
As indicated by nav33n have to include protocols
as long as the web page is stored consistently in the database
just rewrite the php to put the missing part of the uri in the href link

always
www company.com /* broken so the board does not make this a link */

<?php echo "<a href=\"http://".$row_WADAcompanies["Website"]."\">".$row_WADAcompanies["Website"]."</a>"; ?>

or always
company.com

<?php echo "<a href=\"http://www.".$row_WADAcompanies["Website"]."\">".$row_WADAcompanies["Website"]."</a>"; ?>

Thank you both for the help!

The problem is solved everything works as it should.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.