Jump to content

[SOLVED] Simple echo to activate hyperlink field -but I've got it wrong


JTapp

Recommended Posts

Maybe I don't need the $ sign...

 

My original problem is this - FIELDNAME has a website link stored in the database.

The link is being returned, but it is not an 'active' hyperlink.

 

I started out with this :

 

echo $row["FIELDNAME"];

 

Then by playing around, I ended up with my original post.. both are wrong.

 

 

Link to comment
Share on other sites

Hmmm.. Java.. it may be true.. I'm not sure. 

 

Let me approach my problem/question from a different angle.

The following code returns my data just fine into a results.php. 

One of my fields is an Email address - which is displaying the contact email address just fine. 

However, I would like to have the email link activated so the user can click on the email address and Outlook (or whatever) will open.

Below is the code just below the query.. the field name is "Email"

 

 

$result = mysql_query($query) or die(mysql_error());
echo "<table width=\"65%\" border=\"2\" bgcolor=\"#EBECE4\">";
echo "<tr><td><B>District Officer Title<B></td><td><B>First Name<B></td><td><B>Last Name<B></td><td><B>Office Phone<B></td><td><B>Email<B></td></tr>";
while ( $row = mysql_fetch_array($result)) {
echo "<tr><td>". $row['strOfficerTitle'] . "</td><td>" . $row['strFirstName'] . "</td><td>" . $row['strLastName'] . "</td><td>" . $row['OfficePhone'] . "</td><td>" . $row['Email'] . "</td></tr>";
}
echo "</table>";
?>

Link to comment
Share on other sites

I don't think I plugged it in correctly because I get a blank page with this:

 

echo "<tr><td>". $row['strOfficerTitle'] . "</td><td>" . $row['strFirstName'] . "</td><td>" . $row['strLastName'] . "</td><td>" . $row['OfficePhone'] . "</td><td>" . <a href=\"mailto:{$row['Email']}\">{$row['Email']}[/url] . "</td></tr>";

Link to comment
Share on other sites

Stupid broken BBCODE parser ugh. I hate SMF

 

echo "<tr><td>". $row['strOfficerTitle'] . "</td><td>" . $row['strFirstName'] . "</td><td>" . $row['strLastName'] . "</td><td>" . $row['OfficePhone'] . "</td><td><a href=\"mailto:{$row['Email']}\">{$row['Email']}</a></td></tr>";

Link to comment
Share on other sites

Yes, that worked.. thanks!

So, if my 'Email' field was actually 'Website'..  would the following be accurate?

 

echo "<tr><td>". $row['strOfficerTitle'] . "</td><td>" . $row['strFirstName'] . "</td><td>" . $row['strLastName'] . "</td><td>" . $row['OfficePhone'] . "</td><td><a href=\"{$row['Website']}\">{$row['Website']}</a></td></tr>";

Link to comment
Share on other sites

Well, I tried and tried to work with what you provided to me without bugging you again..  but I got nowhere.

I get returned:  [/url]  (which is a link to my own site.)

 

Here is my code - I didn't want the URL link to be in the table, I wanted it to be alone and above it...

 

$result = mysql_query($query) or die(mysql_error());

echo "<p><H2>Website:</H2> <a href=\"{$row['strDistrictWebSite']}\">{$row['strDistrictWebSite']}[/url]</p>";


echo "<table width=\"65%\" border=\"1\" bgcolor=\"#EBECE4\">";
echo "<tr><td><B>District Officers<B></td><td><B>First Name<B></td><td><B>Last Name<B></td><td><B>Office Phone<B></td><td><B>Email<B></td></tr>";
while ( $row = mysql_fetch_array($result)) {
echo "<tr><td>". $row['strOfficerTitle'] . "</td><td>" . $row['strFirstName'] . "</td><td>" . $row['strLastName'] . "</td><td>" . $row['OfficePhone'] . "</td><td><a href=\"mailto:{$row['Email']}\">{$row['Email']}</a></td></tr>";}

echo "</table>";

?>

Link to comment
Share on other sites

I'm not sure what you are asking...(newbie here)

Here is all of my php:

 

  <?php
$username = "username";
$password = "password";
$hostname = "localhost"; 

$dbhandle = mysql_connect($hostname, $username, $password)
or die("Unable to connect to MySQL");

$selected = mysql_select_db("dbb",$dbhandle)
or die("Could not select dbb");

$id = $_POST['search'];
echo "<p><H2>District Number:</b> $id</H2></p>";

$query =  "SELECT a.strLodgeName,
                  a.intLodgeNumber,
                  a.intDistrictID,
                  a.strLodgeMailingCity,
                  a.strLodgeMailingPostCode,
                  b.strDistrictName,
                  b.strDistrictWebSite,
                  c.strOfficerTitle,
                  c.strFirstName,
                  c.strLastName,
                  c.OfficePhone,
                  c.Email
                  FROM tblDistricts AS b
                  LEFT JOIN tblLodges AS a ON b.intDistrictID = a.intDistrictID
                  LEFT JOIN DistrictOfficers AS c ON a.intDistrictID = c.intDistrictID
                  WHERE b.intDistrictID='$id' GROUP BY c.strOfficerTitle LIMIT 5";
$result = mysql_query($query) or die(mysql_error());

echo "<p><H2>District Website:</H2> <a href=\"{$row['strDistrictWebSite']}\">{$row['strDistrictWebSite']}[/url]</p>";


echo "<table width=\"65%\" border=\"1\" bgcolor=\"#dddddd\">";
echo "<tr><td><B>District Officers<B></td><td><B>First Name<B></td><td><B>Last Name<B></td><td><B>Office Phone<B></td><td><B>Email<B></td></tr>";
while ( $row = mysql_fetch_array($result)) {
echo "<tr><td>". $row['strOfficerTitle'] . "</td><td>" . $row['strFirstName'] . "</td><td>" . $row['strLastName'] . "</td><td>" . $row['OfficePhone'] . "</td><td><a href=\"mailto:{$row['Email']}\">{$row['Email']}</a></td></tr>";}

echo "</table>";

?>

Link to comment
Share on other sites

you will have to return the query results first. so you will need to do it before you echo out the link.

 

$result = mysql_query($query) or die(mysql_error());
$link = mysql_fetch_assoc($result);

echo "<p><H2>Website:</H2> <a href=\"{$link['strDistrictWebSite']}\">{$link['strDistrictWebSite']}</a></p>";


echo "<table width=\"65%\" border=\"1\" bgcolor=\"#EBECE4\">";
echo "<tr><td><B>District Officers<B></td><td><B>First Name<B></td><td><B>Last Name<B></td><td><B>Office Phone<B></td><td><B>Email<B></td></tr>";
while ( $row = mysql_fetch_array($result)) {
echo "<tr><td>". $row['strOfficerTitle'] . "</td><td>" . $row['strFirstName'] . "</td><td>" . $row['strLastName'] . "</td><td>" . $row['OfficePhone'] . "</td><td><a href=\"mailto:{$row['Email']}\">{$row['Email']}</a></td></tr>";}

echo "</table>";

?>

 

Not tested but try it out. If not you will need to use an if statement to do it inside the loop.

 

BTW anything in this forum that has [/url] should be replaced with

</a>

. The forum changes the code on it's own.

 

Ray

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.