General Question

newguy09's avatar

Using a PHP page to post "blog" entries on my website.

Asked by newguy09 (1points) October 1st, 2010

I’ve finally managed to setup a page that allows me to submit a message and retrieve it from another page on my website. Now, to go a step further, I’ve setup a news area on my homepage that display recent entries that I’ve made (very similar to a blog.) What I’m trying to do is submit a message on the page I’ve created, fetch it for use on my homepage, and place it right in my news area, and still be able to apply my CSS style to it.

(Additional info.)
On my ‘submittion’ page, it’s a simple php form that has two text areas, one for a title and one for the body of my article. In my stylesheet, I’ve created custom styles for the title and body, but I’m wondering if its possible to apply them, since i’m only retrieiving them rather than coding them into the html.

I hope this wasn’t too confusing. I’m trying to get a grasp on this before i actually settle out to do it. So can anyone give me an idea on how to do this, it can’t be that hard, I just can’t find any tutorials on it.

Observing members: 0 Composing members: 0

4 Answers

jballou's avatar

It shouldn’t be too hard- you’ll probably want to apply the CSS to the page that is retrieving and displaying the information, not the page you use to enter it. Whatever code is generating your HTML output, you can just add the CSS classes, id tags, and DIVs to.

It’s hard to get specific without actually seeing the code.

newguy09's avatar

Thank you for the answer. And yes, I understand, I would show you my code if I had any, but I’m still yet to begin on the project. I was actually hoping to see code examples from some users, because I’ve noticed that there are plenty of developers that use this site. It’s just a small request that would help greatly, but since I don’t have any either, I guess it’s a toss-up.

funkdaddy's avatar

I think the piece you may be missing is the database to store your entries in.

So the first page you describe where the entry is created should write that entry in a way that can be retrieved later. With PHP, the most common way to do this is to use a mySQL database (a tutorial regarding PHP with mySQL), but really you could write to a text file, xml, or something of your own design.

Once you have your data stored your home page and news page would retrieve the entries and loop through them outputting whatever you’d like as html.

So for example you could make it output

echo ’<h1 class=“entry_title”>’ . $title . ’</h1><div class=“entry”>’ . $entry . ’</div>’;

or whatever markup you want to use for your individual entries in each place.

That way you can use CSS to style them.

Does that help?

Zyx's avatar

Settling out is dangerous, take this.

One of the things you might want to look into for moving plain text is heredoc, which basically uses a codeword instead of quotations. That way you can automatically handle all your entries without worrying about quotation marks in them.

Lke @jballou says, a div is probably the way to go, @funkdaddy already has your code. But I have to wonder: do you understand how to make your pages work together? There’s MySQL and a shitload of functions in PHP. There’s SESSIONs and POSTs and GETs, and you need to understand these things before you go looking for code to copy.

Just trying to save you time, honestly.

Answer this question

Login

or

Join

to answer.

This question is in the General Section. Responses must be helpful and on-topic.

Your answer will be saved while you login or join.

Have a question? Ask Fluther!

What do you know more about?
or
Knowledge Networking @ Fluther