donglu7816 2014-10-22 00:35
浏览 13

如果是电子邮件,则将其命名为电子邮件链接!

A form sends name, topic, email, and blurb to MySQL db. Email is not a required field, but if it is !empty I want to include it as the name and echo the row data.

This is my idea so far:

if (!empty($_POST['email']))
{
    $row['name'] = "<A href='mailto:' . $_POST['email'] . '>' . $_POST['name'] . '</A>";
}
else
    {
        $row['name'] = $_POST['name'];
    }

I am having trouble sorting out the coding for the email/name any help please. And the rows will be:

while($row = mysql_fetch_array( $result )) {
    echo "<tr>";
        echo '<td><Posted by : ' . $row['name'] . ' on ' . $row['date'] . '<br />
        Topic : ' . $row['topic'] . '<br />Thoughts : ' . $row['thoughts'] . '</td>';
    echo "</tr>"; 

Not very well sorted yet, help please :-) thanks.

  • 写回答

1条回答 默认 最新

  • dongsui4658 2014-10-22 02:58
    关注

    are you want that if the email is not empty then you want to replace it with name and echo it? if yes then try the below code..

    if (!empty($_POST['email']))
    {
        $row['name'] =$_POST['email'];
    
     $row['name']="<A href='mailto:' . $_POST['email'] . '>' . $_POST['name'] . '</A>";
    }
    else
        {
            $row['name'] = $_POST['name'];
        }
    
    评论

报告相同问题?

悬赏问题

  • ¥15 vue3加ant-design-vue无法渲染出页面
  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
  • ¥15 路易威登官网 里边的参数逆向
  • ¥15 Arduino无法同时连接多个hx711模块,如何解决?
  • ¥50 需求一个up主付费课程
  • ¥20 模型在y分布之外的数据上预测能力不好如何解决
  • ¥15 processing提取音乐节奏
  • ¥15 gg加速器加速游戏时,提示不是x86架构
  • ¥15 python按要求编写程序