Help with a simple CMS

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
connector
Forum Newbie
Posts: 1
Joined: Sat Jul 09, 2011 6:57 am

Help with a simple CMS

Post by connector »

Hello
I am trying to build a simple cms with php, and i have some questions.
first of all i have done the tables in mysql, i have 3 tables, first is called "posts" which holds the articles that i submit, the other one is the "categories" to show which category the post belongs to, and the last table is "users" table just to allow the admin to login in. the admin panel has been done where i post new articles to mysql database.

what i want to do :
1) to show 10 articles per page ( i have already found a pagination class but would like to hear your comments, link :
http://net.tutsplus.com/tutorials/php/h ... -with-php/
)
how this thing can be done ?

2) have my posts under their category
http://mysite/category/article

e.g. :
http://mysite/php/1-hello-world-test
http://mysite/cplusplus/2-using-function
http://mysite/visualbasic/3-events-handling
as you can see every article would have an id number with auto-increment property.
so how i would make those urls with the title of the article on them ?

i know the theory but i can't implement it so i would appreciate any comment and suggestion on how this should be done .
Thanks
danniehansen
Forum Newbie
Posts: 3
Joined: Sat Jul 09, 2011 10:47 pm

Re: Help with a simple CMS

Post by danniehansen »

1)
I like to call this one paging. Usually i go ahead and count the records of articles or whatever we're looking at. Then i divide it by the number of articles shown per page and boom you suddenly got how many pages you need to make.
Then if it's over 1 page you just print out the first 10 with LIMIT 0,10 - For the rest of the pages you just change the limit.

2) - Not sure about the question so you get 2 answers :) Take the one you think fits.

1 -
You simply combine your tables. Having a category table for categorys and a article table for articles. Then when you select your articles you can have a fields with the category id. Then you can always do a join to get name of the category(You might ask your self why not just write the category name aswell in the article table. It's simple, any data being repeated should be in a relation table.).

2 -
Well it seems to me like they store their HTML / Content in html files. This is a known technique which i used a few times. Works just similar to cache. Insteed of having to lead huge amount of HTML/CSS or other stuff from the database to overload it you simply store all your content in files locally. There might be another way but I'm not too sure about it.


Hope you found any of these answers useful. Got any questions? Fell free to send me a PM.
Post Reply