简体   繁体   中英

Handling content for Blog - Database

let's say i want to create a blog and are then going to handle text, links, images and so on, but how would i save this into a database?

Here's a random example.

Example - Text:

Hello, this is my blog. Check out this site! Cakes:

  1. Cookie
  2. Muffin

Example - HTML:

<p>Hello, this is my blog.</p>
<p>Check out this <a href="google.com">site</a>!</p>
<p>Cakes:</p>

<ol>
  <li>Cookie</li>
  <li>Muffin</a>
</ol>

Would i just save the HTML into the database or how should i handle this? Can't see any other way.

If all your post are going to have the same sections you could save just data. For example, if your blog is about cooking, so you can save only list of ingredients, steps to prepare, description, name, etc. But if it is about different topics and you can not identify a pattern, so you will need to save the html to database.

Yes, you save the whole HTML into database, for images either you save the link or using server side language you just save path for your image and save the image in a particular folder then add the path into database. Example you a folder named images in you root folder of server. then you save <img src="images/imagename.jpg" alt="image"> .

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