ComputerForum.com ComputerForum.com  
TigerDirect
 
Go Back   Computer Forum > Computer Software > General Software

Reply
 
LinkBack Thread Tools Display Modes
Old 08-05-2005, 10:02 AM   #1 (permalink)
Bronze Member
 
fayax's Avatar
 
Join Date: Aug 2004
Location: Maldives
Age: 23
Posts: 44
Default PHP Parameter / link indexing

I want to know how can I index links in a single file.

E.g.1 (http://www.myserver.com/topics.php?ID=introduction)
E.g.2 (http://www.myserver.com/topics.php?ID=general)
E.g.3 (http://www.myserver.com/topics.php?ID=overview)

In the examples, the main file is "topics.php" with different parameter.
If we change the parameter, the contents will change.

What I want to know is how can I make that.

Thanks in advance.
fayax is offline   Reply With Quote


Old 08-05-2005, 02:12 PM   #2 (permalink)
Moderator
 
Cromewell's Avatar
 
Join Date: Dec 2004
Location: Canada
Age: 25
Posts: 10,191
Default

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.
__________________

You know what the chain of command is? It's the chain I go get and beat you with 'til ya understand who's in ruttin' command here.

I must plug a couple comics because they are good :D:
www.ctrlaltdel-online.com
www.userfriendly.org
Cromewell is offline   Reply With Quote
Old 08-05-2005, 05:05 PM   #3 (permalink)
Bronze Member
 
fayax's Avatar
 
Join Date: Aug 2004
Location: Maldives
Age: 23
Posts: 44
Default 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?
fayax is offline   Reply With Quote
Old 08-05-2005, 05:46 PM   #4 (permalink)
Moderator
 
Cromewell's Avatar
 
Join Date: Dec 2004
Location: Canada
Age: 25
Posts: 10,191
Default

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.
__________________

You know what the chain of command is? It's the chain I go get and beat you with 'til ya understand who's in ruttin' command here.

I must plug a couple comics because they are good :D:
www.ctrlaltdel-online.com
www.userfriendly.org
Cromewell is offline   Reply With Quote
Old 08-05-2005, 08:05 PM   #5 (permalink)
Bronze Member
 
fayax's Avatar
 
Join Date: Aug 2004
Location: Maldives
Age: 23
Posts: 44
Default

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!
fayax is offline   Reply With Quote


Old 08-05-2005, 08:08 PM   #6 (permalink)
Moderator
 
Cromewell's Avatar
 
Join Date: Dec 2004
Location: Canada
Age: 25
Posts: 10,191
Default

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.
__________________

You know what the chain of command is? It's the chain I go get and beat you with 'til ya understand who's in ruttin' command here.

I must plug a couple comics because they are good :D:
www.ctrlaltdel-online.com
www.userfriendly.org
Cromewell is offline   Reply With Quote
Old 08-05-2005, 08:37 PM   #7 (permalink)
Bronze Member
 
fayax's Avatar
 
Join Date: Aug 2004
Location: Maldives
Age: 23
Posts: 44
Default

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!
fayax is offline   Reply With Quote
Old 08-05-2005, 08:56 PM   #8 (permalink)
Moderator
 
Cromewell's Avatar
 
Join Date: Dec 2004
Location: Canada
Age: 25
Posts: 10,191
Default

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 Code:
...
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;
}
... 
__________________

You know what the chain of command is? It's the chain I go get and beat you with 'til ya understand who's in ruttin' command here.

I must plug a couple comics because they are good :D:
www.ctrlaltdel-online.com
www.userfriendly.org

Last edited by Cromewell; 08-07-2005 at 07:29 AM.
Cromewell is offline   Reply With Quote
Old 08-06-2005, 05:55 AM   #9 (permalink)
Bronze Member
 
fayax's Avatar
 
Join Date: Aug 2004
Location: Maldives
Age: 23
Posts: 44
Default

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
fayax is offline   Reply With Quote
Old 08-07-2005, 07:31 AM   #10 (permalink)
Moderator
 
Cromewell's Avatar
 
Join Date: Dec 2004
Location: Canada
Age: 25
Posts: 10,191
Default

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
__________________

You know what the chain of command is? It's the chain I go get and beat you with 'til ya understand who's in ruttin' command here.

I must plug a couple comics because they are good :D:
www.ctrlaltdel-online.com
www.userfriendly.org
Cromewell is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 10:17 AM.


Powered by: vBulletin Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0 ©2008, Crawlability, Inc.
Copyright © 2002-2008 Computer Forum and Web Design Forum