Script Garage

 

How do you make a simple content change with php script?

OK, so I'm knew to php. But the only way to learn it is to try, right? So i'm trying to make a simple 5 page web site. I want to use one layout and I want to be able to switch content of the page by clicking a link and using php. If you know how to do this simple script please show me in detail. Thank you. Yes, its only 1 Template. ANd... this answer (you can also do this with redirects in .htaccess and build onlyone actual page). this sounds like what I"m looking for. Using only one page that redirects info. how do you do this?

Public Comments

  1. What you mean by one layout is a template page? This is a bit of a shell: Make 5 target pages in php, eg. index.php, about.php, products.php, etc (you can also do this with redirects in .htaccess and build onlyone actual page). Each page contains about this much code (in php): include "common.inc.php" which will bring in all your common functions that you need (database login, header generation, page generator). You then invoke a page generator function naming the file or database element containgin your content. Each page will need all of 3 to 5 lines of script and thats it. The page generator reads your standard layout file, which contains words like {$title$}, {$menu$}, {$content$} or other unique and easy to identify things where these should be. As the generator gets input from the layout page and runs into these things, you have it substitute stuff from your content file or database. There are about 5 variations on this, and each does the trick. ADDED: in .htaccess, a bunch of these.. Redirect /index.html http://mysite.com/site.php Redirect /about.html http://mysite.com/site.php ... Then in site.php, pick up the url from the the redirect info (exact php variable name escapes me), then if( $redirectfrom = 'http:/mysite.com/index.htm' )... if( $redirectfrom = 'http:/mysite.com/about.htm' )...
Powered by Yahoo! Answers