down00112 2014-11-09 02:31
浏览 68
已采纳

悬停文本仅显示第一个单词

I am trying to display popup text when I hover over some other text. The popup text will only display the first word. I am rather new to php and such, so I hope this is not an idiotic question, but what am I doing wrong here?

while ($row = mysql_fetch_array($data)) {
    $description = $row[2];
    echo $description;  //output:  "Get an Automatic..."
    echo "<a title=$description>";  //Hover output:  "Get"
    echo "blah blah blah";
    echo "</a>;
}
  • 写回答

2条回答 默认 最新

  • doujizhong8352 2014-11-09 02:32
    关注

    You need to wrap them with quotes:

    echo "<a title='$description'>"
    

    Sidenote: It's also important that you might get strings like this:

    Get an automatic test's
    

    That will surely mess up that quoting, and terminate it early, might be better to add htmlspecialchars() in that case:

    $description = htmlspecialchars($row[2], ENT_QUOTES);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!