PHP Parameter / link indexing

You mean like this form works? Basically you need the page content in an SQL table (or somewhere else you can easily look for it with out needed special code for each page) then you just take $_GET['ID'] and look for the matching content.
 
php paremeter / indexing

yeah, i mean like this forum work. But I don't want to use a database.
Is it possible to make it using "echo" or "print" statement to display the content and "if" or "isset" statement as switch?
 
It is possible but IMO that's a pointless endaevour. The purpose of having a system like this forum uses is so that the same page can hold different content. The page itself isn't in the database, only the body content. Using the forum as an example, basically only the post text, poster id and date are stored in the database. showthread.php has a page template that it uses as a base then adds the thread specific content.
 
same thing happen in this forum. but I'm talking about the simple way.
The only thing I want to change is the headline of the topic and its contents.

Lets say I'm going to make a short description about my country.
Substitute "index.php" as main page. and "view" as a switch or parameter.

If I point my browser direct to "index.php" it will display a short description about Maldives. And if I include the parameter "index.php?view=climate", it will tell about the Climate.

So no need of database.. am I correct?

Have you got any idea? If you still didn't understant, just ask me.

Thank you!
 
No you don't need a database, but ideally you need somewhere to store the climate information or what ever bit you'd like to put on the page. It could be all in the php script with different echos for each part but that would make a big file and sort of defeats the purpose or using php and you could just use a series of html pages.
 
I can store the climate information in a separate file, so I can use "include" statement in the main php file. I'm not sure about it. thats just an idea.

If you think we can do it by that way, can you show me a sample code?

Thank you!
 
assuming you have a template file (I'm going to use a placeholder for it) and it has sections easily marked to be replaced (I use {sectionname} ). This isn't a complete script but it should help you get started
PHP:
...
if ($_GET['id'] == "climate"){ //read get variable
  $page = file("template.htm"); //load template web page

  $page_str = implode("",$page);
  $page_str = str_replace("{title}","Climate Details", $page_str); //replace {title} with 'Climate Details'

  $page_content = file("climate.txt"); //this file can have html formating, just dont have the <html>, <title>, <head>, <body> or their respective closing tags in it
  $page_content = implode("",$page_content);
  $page_str = str_replace("{body}",$page_content, $page_str);
  echo $page_str;
}
...
 
Last edited:
it didn't show up anything just a blank page.
if you want to check my script email me. fayaz at hinmaiy.com.mv


thank you
 
I think you are forgetting to add the get variables (you should have <domain>/index.php?id=climate in the address bar) also note the slight bug I had in the code to repace the body text, it's fixed now
 
Back
Top