vetman Posted September 22, 2008 Share Posted September 22, 2008 I am new to php and msyql and am having a problem with making an email address in a table a link so I can send email. I can get the information from the database but when I try to make the email address a link it won't work. Any help would be appreciated! Thanks in advance. Here is my code: <?php // Make a MySQL Connection include 'config.php'; //include 'style_1.php'; $con = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql'); mysql_select_db("vetmanpc") or die(mysql_error()); $result = mysql_query("SELECT * FROM lakestmill") or die(mysql_error()); // store the record of the "lakestmill" table into $row $current = ''; // keeps getting the next row until there are no more to get while($row = mysql_fetch_array( $result )) { $id = $row['id']; if (!$current) { echo "<div><table border='1' width='300'>"; $current = $id; } elseif ($current != $id){ echo "</table></div><br><br><div><table border='1' width='300'>"; $current = $id; } // Print out the contents of each row into a table echo "<tr><th width='80' height='3'> Unit No.</th><td>{$row['unit']}</td></tr>"; echo "<tr><th height='3'> Company</th><td>{$row['company']}</td></tr>"; echo "<tr><th height='3'> FirstName</th><td>{$row['firstname']}</td></tr>"; echo "<tr><th height='3'> LastName</th><td>{$row['lastname']}</td></tr>"; echo "<tr><th height='3'> Email</th><td><a href="{$row['email']}"</a></td></tr>"; echo "<tr><th height='3'> Address</th><td>{$row['address']}</td></tr>"; echo "<tr><th height='3'> City</th><td>{$row['city']}</td></tr>"; echo "<tr><th height='3'> State</th><td>{$row['state']}</td></tr>"; echo "<tr><th height='3'> Zip Code</th><td>{$row['zip']}</td></tr>"; echo "<tr><th height='3'> Phone</th><td>{$row['phone']}</td></tr></div>"; } echo "</table></div>"; ?> Quote Link to comment Share on other sites More sharing options...
nutstretch Posted September 22, 2008 Share Posted September 22, 2008 I use <a href='mailto:$email' >$email</a> Hope this helps Nuts Quote Link to comment Share on other sites More sharing options...
vetman Posted September 22, 2008 Author Share Posted September 22, 2008 Thanks for the fast reply, but that didn't work. What it did was place a blank in each table where the email address was before. Quote Link to comment Share on other sites More sharing options...
ranjuvs Posted September 22, 2008 Share Posted September 22, 2008 Try this echo "<tr><th height='3'> Email</th><td><a href=\"mailto:$row['email']\">$row['email']</a></td></tr>"; Quote Link to comment Share on other sites More sharing options...
vetman Posted September 22, 2008 Author Share Posted September 22, 2008 I'm getting this error: Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/content/r/i/g/rigtway/html/demo/lake_st.php on line 46 Quote Link to comment Share on other sites More sharing options...
ranjuvs Posted September 22, 2008 Share Posted September 22, 2008 ok then try this $email = $row['email']; echo "<tr><th height='3'> Email</th><td><a href='mailto:$email'>$email</a></td></tr>"; Quote Link to comment Share on other sites More sharing options...
vetman Posted September 22, 2008 Author Share Posted September 22, 2008 That works, thanks. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.