| | |||||
| ||||||||
| Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics. |
![]() |
| | LinkBack | Thread Tools |
| | THREAD STARTER #1 (permalink) |
| NamePros Member Join Date: Mar 2005
Posts: 36
![]() | PHP - Changing only center of page with links Ok, this is the page I'm working on: http://www.clan-loh.com/dynasty/week...tars2005w1.php It's set up in php such that a php file builds all the outside stuff, the header at the top of the page, the links on the left side, all the colors, etc. The middle part (the weekly all-stars) are an html report generated by some fantasy football software. I put that in there with a simple include statement for the html file I am given. What I would like to do is have the links up above that table (Week : 1 2 3 4 etc) change ONLY that middle file. That way I could have ONE php file called say "all-stars.php" that builds the page, and then 17 html files called say "week1.htm", "week2.htm" etc that it can link to. As it is now I have 17 php files "all-stars-week1.php" etc and 17 html files to go with them. ????: NamePros.com http://www.namepros.com/programming/125165-php-changing-only-center-page-links.html I'm pretty sure there's a way to be able to just create one php file that has a switch statement or something of the like and chooses the proper html file depending on what value was passed in from the link, but I'm a bit amiss as to how exactly to get each of the links to pass in the values. Looked around some but it's kind of a difficult thing to search for since it's not a distinct keyword. Any quick help? Thanks in advance! |
| |
| | #3 (permalink) |
| NamePros Regular Join Date: Jun 2004
Posts: 587
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | Do it this way: Have an "main" php file that controls the script execution. In the "main php" script, do includes for all of the header and nav bar stuff. Then make each week a hyperlink that links to the main php script, but passes the week as a parameter. Example: PHP Code: Now, you can get the value passed from the hyperlink like this: PHP Code: Example: PHP Code: Hope this helps. Happy coding. -Bob
__________________ Can't wait to be out of this forsaken business. Getting close! :) |
| |
| | #4 (permalink) |
| NamePros Regular Join Date: Aug 2005
Posts: 214
![]() | Example: PHP Code: PHP Code: Mike Or
__________________ OnlineGames.net |
| |
| | #5 (permalink) | ||||
| NamePros Regular Join Date: Jun 2004
Posts: 587
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
And this is what I love about programming. There is more than one way to skin a cat. -Bob
__________________ Can't wait to be out of this forsaken business. Getting close! :) | ||||
| |
| | THREAD STARTER #6 (permalink) |
| NamePros Member Join Date: Mar 2005
Posts: 36
![]() | Perfect, that's exactly what I was looking for. Thanks fellas. While I've got you all here. Is there any way for me to kill the "file does not exist error" when they click on the link for a week that isn't up yet. For instance, it's only week 2, so if they click on week 8 it looks for the week 8 file and returns a php error. Can I either A) make this error not show up so they just get a blank page with the links to the weeks or B) give a more user-friendly error, such as "There are no all-stars for this week yet" Did a search on php error reporting and could only find stuff on php errors, not how to write error reporting of your own. |
| |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Tutorial: Getting started with PHP (The Basics) | deadserious | Webmaster Tutorials | 60 | 11-17-2007 12:35 PM |
| Tutorial: Simple site management with the use of PHP and the query string(?page=1) | deadserious | Webmaster Tutorials | 8 | 10-09-2004 02:20 PM |
| Tutorial: Using PHP require() & include() | Dave S | Webmaster Tutorials | 5 | 03-22-2004 01:40 AM |
| Deleted Domain List Site FREE | dropscripts | For Sale / Advertising Board | 12 | 09-24-2003 08:16 AM |