Jump to content

what is page id


mraza

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/175920-what-is-page-id/
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/175920-what-is-page-id/#findComment-926984
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/175920-what-is-page-id/#findComment-926985
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/175920-what-is-page-id/#findComment-926996
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/175920-what-is-page-id/#findComment-927019
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.