Jump to content

Newbie cms page question


Drongo_III

Recommended Posts

Hi Guys

 

Just learning php.

 

I want to write my own simple cms to get to grips with how things work (not necessarily to use as i realise there are millions of open source cmses available that are much more secure and clever).

 

 

I'm ok with capturing and storing data in a database and i know the rudmiments of php so far.

 

What i'm not so clear about, and what's missing from all the tutorials i've read, is how you load the data stored in a database relating to a specific page. All examples i've seen simply access the database and dump all the content into a page.

 

So lets say i stored some body text in a database table with a unique key of 4.

 

I then click on a link somewhere in the website, lets say it's www.mysite.com/4 (lets assume i've done the clever stuff with .htaccess)

 

What is the best way of loading that specific page content?

 

Do you access the header url and strip out the end part? Then compare that to your database ? Or is there a better way?

 

Sorry if this is vague i'm just after a brief explanation and i'll go do the leg work to find out how to do it :)

 

Thank you!

Link to comment
Share on other sites

Hi Quick

 

Thanks for your post. I get what you've said but that just leaves me with the mystery of how you tell the script what look for. So if I've clicked on a link for www.mysite.com/4, then how do i tell the script that the user has clicked on a link and wants to visit page 4?

 

Sorry if i'm being slow and missing something obvious :/

 

 

That unique key of 4 you speak of could be a GET value, doing an if/else statement of the GET could determine what content is displayed on the same page by using includes or writing the different mysql queries inside the if/else statement.

Link to comment
Share on other sites

Let me give you a few demo of codes I wrote up and can look at them a bit.

 

A simple navigation

http://get.blogdns.com/navigation/

 

This one creates single posts

http://get.blogdns.com/dynaindex/post-variable.php

 

Here's some pagination ones.

http://get.blogdns.com/paginate/

http://get.blogdns.com/dynaindex/paginate.php

 

A post in the forum parsing urls

http://www.phpfreaks.com/forums/index.php?topic=319755.0

 

This is the function code to find path one

http://www.phpfreaks.com/forums/index.php?topic=319755.msg1506929#msg1506929

 

If any more questions feel free to ask.

Link to comment
Share on other sites

 

Thanks for all the info Quick!

 

I think I have a much better idea of how it's done now. Looks to be a case of appending IDs to each link via query strings and i suppose i can then use that info to dynamically load specific content from the database. Going to have a fiddle and will let you know if i have any questions.

 

Thanks loads for all the links and info! :)

 

Let me give you a few demo of codes I wrote up and can look at them a bit.

 

A simple navigation

http://get.blogdns.com/navigation/

 

This one creates single posts

http://get.blogdns.com/dynaindex/post-variable.php

 

Here's some pagination ones.

http://get.blogdns.com/paginate/

http://get.blogdns.com/dynaindex/paginate.php

 

A post in the forum parsing urls

http://www.phpfreaks.com/forums/index.php?topic=319755.0

 

This is the function code to find path one

http://www.phpfreaks.com/forums/index.php?topic=319755.msg1506929#msg1506929

 

If any more questions feel free to ask.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.