Reputation: 69
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:
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.
Upvotes: 0
Views: 333
Reputation: 474
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">
.
Upvotes: 0
Reputation: 627
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.
Upvotes: 3