mraza Posted September 29, 2009 Share Posted September 29, 2009 Hi again ! currently i am developing a site with PHP ..i am not so expert in PHP and i am developing my first site with it. i am using include to add content at my index page like header footer etc. Now what i exactly wants to know is i saw on some sites when i will click on a link it will show a page like this index.php?id=124 .. what exactly is happening here and how can i call a page or give an id number to my other pages. thanks for any help Quote Link to comment https://forums.phpfreaks.com/topic/175920-what-is-page-id/ Share on other sites More sharing options...
Adam Posted September 29, 2009 Share Posted September 29, 2009 The page id is just a reference to content stored in another location - be it a template, database, etc. You collect the page id within the script and use that to locate and include / echo / basically print out the contents. There's many methods of doing this though. Quote Link to comment https://forums.phpfreaks.com/topic/175920-what-is-page-id/#findComment-926984 Share on other sites More sharing options...
mraza Posted September 29, 2009 Author Share Posted September 29, 2009 ok thanks for reply but really i dont get it. how can i pass a refrence to a page . currently i have created index page and now i was going to create second page for "About Us" and link to it as hyperlink in HTML. how can i give id to that page and then link from my index page. Quote Link to comment https://forums.phpfreaks.com/topic/175920-what-is-page-id/#findComment-926985 Share on other sites More sharing options...
Adam Posted September 29, 2009 Share Posted September 29, 2009 Okay, what method would you like to store the content (template files / database)? Quote Link to comment https://forums.phpfreaks.com/topic/175920-what-is-page-id/#findComment-926988 Share on other sites More sharing options...
mraza Posted September 29, 2009 Author Share Posted September 29, 2009 template files only .. i dont have any database method Quote Link to comment https://forums.phpfreaks.com/topic/175920-what-is-page-id/#findComment-926995 Share on other sites More sharing options...
cags Posted September 29, 2009 Share Posted September 29, 2009 As MrAdam already said there are lots of ways of doing it. Basically what you are talking about is a CMS (content management system). The idea revolves around information being stored somewhere, generally in a database, and then included in the file, as and when required. An example of it at it's most basic. Imagine you have a database table like so. Database Table ==== id, page_name, page_link, page_content On your index page you could use something like... <?php if(isset($_GET['id'])) { // display requested page $sql = "SELECT * FROM `table` WHERE id=" . $_GET['id']; $result = mysql_query($sql); $row = mysql_fetch_assoc($result); echo '<h1>' . $row['page_name'] . '</h1>'; echo '<p>' . $row['page_content'] . '</p>'; } else { // display list of pages $sql = "SELECT `id`, `page_link` FROM `table`"; $result = mysql_query($sql); while($row = mysql_fetch_assoc($result)) { echo '<a href="index.php&page=' . $row['id'] . '" />' . $row['page_link'] . '</a>'; } } ?> Bare in mind that is a far from secure script, it doesn't check for errors or anything, but it will hopefully give you an idea of how it works. If it doesn't there are many, many tutorials available for coding CMS systems. I'm sure theres one here on PHPFreaks (I'm new so I don't know for sure), if not theres certainly one at PHPAcademy.info and at DevelopPHP.com Quote Link to comment https://forums.phpfreaks.com/topic/175920-what-is-page-id/#findComment-926996 Share on other sites More sharing options...
mraza Posted September 29, 2009 Author Share Posted September 29, 2009 Thanks you both. and cags it was really informatics specially DevelopPHP.com where i found a good tutorial to build a CMS. In fact i am not so fimiliar with PHP i have cleared the basics of PHP except OOP and wants to start practically by building a PHP site so can understand better. can you guys point me some other tutorials too about CMS from scratch. Thanks again Quote Link to comment https://forums.phpfreaks.com/topic/175920-what-is-page-id/#findComment-927019 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.