I want to do something very basic and have tried many ways without success. I have a simple database table consisting of four fields. All it is doing is showing affiliated clubs. One field is 'webaddress' which is the http address.
I want to make "title' into a hyperlink so that the club title is displayed but if you click on 'title' it goes to their website, opening in a new window.
Amazingly I cannot find any reference to this in any tutorial.

<h2>"<?php echo $row_rsClubs; ?></h2>
<p><?php echo $row_rsClubs; ?> </p>

Can anyone help?

Recommended Answers

All 4 Replies

You have two options. Hard code the address to the club in the php or add a field to the database table holds the link. I would highly recommend adding a field with in the database that contains the URL associated with the club.

I used different names for the fields so you'll have to change them accordingly.

Example:

<h2><?php echo $row_rsClubs['ClubName']; ?></h2>
  <a href="<? echo $row_rsClubs['Link']; ?>" > <?php echo $row_rsClubs['ClubName']; ?> </a>

This should print the club name in the <h2> with a link where you can click the club name below. You can also put the <h2> tags in the <a> tag like this.

<a href="<? echo $row_rsClubs['Link']; ?>" ><h2> <?php echo $row_rsClubs['ClubName']; ?></h2> </a>

Many thanks, that's brilliant. Just one more point! Where does the target="_blank" go in example two?

<a href="<? echo $row_rsClubs['Link']; ?>" target="_blank"  ><h2> <?php echo $row_rsClubs['ClubName']; ?></h2> </a>
<a href="<? echo $row_rsClubs['Link']; ?>"  (anything can go here, i.e. target="_blank" class="aClass" etc. ><h2> <?php echo $row_rsClubs['ClubName']; ?></h2> </a>

Many thanks, I thought I had tried this route but obviously I had got something wrong! Great relief!

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.