View Full Version : Text editing AND automatic blog posting

05-08-2011, 03:41 PM
Hello everyone.
For the site that I am making, I also made my own blog-writer.
This is going to be a double question.

1. Text editing.
Okay, so I write my blog in a textarea:

<p class="p2">Content:</p>
<textarea name="content" style="height: 200px; width: 400px;"></textarea
What I would like to have is some sort of thing like you have on most fora, like on this one, where I have a simple series of buttons:
bold - italic - underline - align buttons - img links - links
I don't exactly know how to get started. All I want is when I click on a certain button (e.g.:the bold button) that <b></b> tags appear.
Does anyone have any idea on how to do this?

2. Automatic blog posting & timestamp.
What I also would like to have is some sort of thing that records the current date in this order, e.g.: 15:31 Sun 8 May 2011.
The thing is that I insert the blog (title, author, content, date) into my database, but that I don't know how to automatically post it onto my blog page, added to the ones I already have (with the timestamp included), ordered by date (3 max per page, separated by pages)
e.g.: I click sumbit -->php inserts the values into my database--> my current blog/previous blog1/previous blog 3

I was thinking about doing it with a while loop, which constantly checks if there are new posts, but I don't know how toexactly do that, and I don't actually know how to move the last blog post on page 1,2,3,... to the next page. :)
I'm not asking for fully made code, I'm just looking for an idea, since I want to develop myself in coding, but this thing is something that I was unable to freely find on the net.

Please help me. :)

05-08-2011, 06:45 PM
1) Google for ckeditor - far easier, superior to most forum editors and it will integrate directly into your site saving you a lot of work.

2) Seems to be a question of multiple questions leading to an entire blog script being written for you. Break it down into smaller questions and you'll get a clearer set of answers.

Check out the date() and time() functions on php.net for a start - that will show you how to use and work with timestamps and their formats.

05-08-2011, 11:33 PM
Haha, yeah sorry, I was trying to define my question a bit, but I barely had time so it all had to be done very quickly.
In the meantime, I figured out how to do all of it.
Here's how I display my blogs on my website:
by using a while loop, a new blog directly gets added onto the page, last posted one up top.
It also displays the time it was post (the moment it went into the database), just by writing $timestamp = time() right before the inserts. Then, when I get that 11 digit inux stamp out of the database, I convert it and display it. I also order it descending.

So that part was fixed by myself. Thanks for the text editor, I'll check it out, but tbh I think I'll do it the hard way and do it on my own, with JavaScript. Rather do that than be lazy :D

Anyway; I have a question regarding those blogs. Right now I got none posted, but I'd like to keep the limit to 4/page. How is this possible?
I'm thinking about something where I have my pages premade (e.g.: ../blogs/blog_pg#1 2 3 And so on, and where I check with a while loop if there are more than 4 posts on the page, and if that is so, the oldest one would be moved to the next page.

My question here is: is there any way how you can easily move stuff to the next page?

05-09-2011, 12:07 AM
You need to look up pagination. Since all websites are different in some way one method might not work the same way for you as it does someone else - you need to find some code on google somewhere which will work for you.

Limiting the number of enties is easy - "select * from blogs limit 4"

Note the limit 4 thing which must be at the end of your sql. You can use "order by date asc/desc limit 4" too.