Solved

Database query - turn field to mailto

Posted on 2006-07-23
1
230 Views
Last Modified: 2008-03-06
Ok - first thing - I know nothing about PHP what so ever.

I have a mysql db which this script is quering and it works.

However, i would like to make the Emails field a mailto and if possible set the subject of that email.

Any help would be greatly appreciated.

(this code came from a tutorial so if im doing anything wrong please let me know)

Thanks in advance

Paul





<html>
<body>
<?php

$db = mysql_connect("localhost", "users");

mysql_select_db("bentleys",$db);

$result = mysql_query("SELECT * FROM Awareness",$db);

if ($myrow = mysql_fetch_array($result)) {

  echo "<table border=1>\n";

  echo "<tr><td>Full Name</td><td>Status</td><td>Description</td><td>Email Address</td></tr>\n";

  do {

          printf("<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</a></tr>\n", $myrow["Fullname"], $myrow["Status"], $myrow["Description"],$myrow["Emails"]);

  } while ($myrow = mysql_fetch_array($result));

      echo "</table>\n";

} else {

      echo "Sorry, no records were found!";      

}

?>

</body>

</html>












</body>



</html>


0
Comment
Question by:bentbris
1 Comment
 
LVL 8

Accepted Solution

by:
RWJDCom earned 125 total points
ID: 17165177
Just change ...

printf("<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</a></tr>\n", $myrow["Fullname"], $myrow["Status"], $myrow["Description"],$myrow["Emails"]);

to

echo "<tr><td>" . $myrow['Fullname'] . "</td><td>" . $myrow['Status'] . "</td><td>" . $myrow['Description'] . "</td><td><a href=\"mailto:" . $myrow['Emails'] . "?subject=test subject\">" . $myrow['Emails'] . "</tr>\n";

That should work for you.
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to count occurrences of each item in an array.

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question