简体   繁体   中英

Link is not showing properly from database

In my cakephp project I am trying to show a link from a database table.

Here is the text field. Here I have sent a link in my database table

在此输入图像描述

After Inserting this link my database table looks like the image below

在此输入图像描述

Now the problem is when I want to see this link in my view page It's showing something like the image below

在此输入图像描述

This is my view code --

<div>
    <p style="font-size: 1.0em;">
       <?php echo h($notice['Notice']['description']); ?>
      </p>
</div>

Now my questions are:

How can I show the link?

Is there any role in mysql query for showing link?

I have used data type text is this the right way?

Your HTML link is being escaped by the h function that your are using to print it.

See http://api.cakephp.org/2.2/function-h.html

Text to wrap through htmlspecialchars

And what's htmlspecialchars?

http://us2.php.net/htmlspecialchars

It means it turns special characters which have meaning in html code into their entity representations, such as '>' for '>'. This means they are printed on screen the way they appear in the code instead of actually becoming HTML tags.

Instead of running the data through the h function, simply echo it.

<div>
  <p style="font-size: 1.0em;">
     <?php echo $notice['Notice']['description']; ?>
  </p>
</div>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM