How to make a blog template? (HELP IS NEEDED) | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How to make a blog template? (HELP IS NEEDED)

I am at the blog stage in my website and I have made a layout for an individual blog post (eg. TItle, article, author name) and I have also made the "preview" layout (eg. a image related to the blog and a small description of blog). I want people to be able to click on the preview and have it open straight to the real blog. How do I do this? I also dont want to make a new HTML file for every blog layout I have to make because I will write alot of blogs, what can I do for this? Much help is needed!! Thanks in advance.

10th Jun 2018, 2:53 AM
Kyle
Kyle - avatar
8 Answers
+ 4
It’s a big task to explain but. Store your articles in mysql and query them with id parameter blog.php?id=1
10th Jun 2018, 4:17 AM
Toni Isotalo
Toni Isotalo - avatar
+ 3
Yes php. Make one page for you blogs.
10th Jun 2018, 4:49 AM
Toni Isotalo
Toni Isotalo - avatar
+ 3
No it does not. look up sql course too. It could be something like this. Links for your blogs $q = $db->query(”SELECT * FROM articles”); foreach($q as $row) { $id = $row[”id”]; $title = $row[”title”]; echo ”<a href=’blog.php?id=” . $id . ”’>$title</a>”; } blog.php?id=1 $id = $_GET[”id”]; $pre = $db->prepare(”SELECT * FROM articles WHERE id=:id”)( $pre->bindParam(”:id”, $id); $pre->execute(); $row = $pre->fetch(); echo $row[”title”]; echo $row[”article”]; echo $row[”author”];
10th Jun 2018, 5:03 AM
Toni Isotalo
Toni Isotalo - avatar
+ 1
Please link to your code here so we can see it. Cheers.
10th Jun 2018, 4:03 AM
Tony
Tony - avatar
+ 1
so i would use PHP?
10th Jun 2018, 4:47 AM
Kyle
Kyle - avatar
+ 1
okay thanks! im learning php, just started today but im already half way through! does the course say anything about what your talking about?
10th Jun 2018, 4:56 AM
Kyle
Kyle - avatar
+ 1
Okay ill keep this in mind! Thanks Toni!
10th Jun 2018, 5:06 AM
Kyle
Kyle - avatar
0
Its nothing to do with my website, its how do i make a template that stays permanent without having to make a new file everytimd, and how do i make a preview layout that immediatley links to the main blog
10th Jun 2018, 4:05 AM
Kyle
Kyle - avatar