NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page PHP - Changing only center of page with links

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.

Advanced Search


Closed Thread
 
LinkBack Thread Tools
Old 09-19-2005, 11:24 PM THREAD STARTER               #1 (permalink)
NamePros Member
Join Date: Mar 2005
Posts: 36
FreeBaGeL is an unknown quantity at this point
 



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!
FreeBaGeL is offline  
Old 09-20-2005, 12:03 AM   #2 (permalink)
NamePros Regular
 
dkin69's Avatar
Join Date: May 2005
Posts: 358
dkin69 has a spectacular aura aboutdkin69 has a spectacular aura about
 



I dont believe there is a way to do this other than frames.
dkin69 is offline  
Old 09-20-2005, 06:58 AM   #3 (permalink)
NamePros Regular
 
moondog's Avatar
Join Date: Jun 2004
Posts: 587
moondog is a name known to allmoondog is a name known to allmoondog is a name known to allmoondog is a name known to allmoondog is a name known to allmoondog is a name known to allmoondog is a name known to allmoondog is a name known to all
 



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:
<a href='script.php?week=1'>1</a> <a href='script.php?week=2'>2</a
Etc Etc.

Now, you can get the value passed from the hyperlink like this:

PHP Code:
$week $_GET[week]; 
From there, you can include the appropriate HTML/PHP file to display the correct week.

Example:
PHP Code:
if($week==1) {include('AllStars2005w1.php');}
????: NamePros.com http://www.namepros.com/showthread.php?t=125165
????: NamePros.com http://www.namepros.com/showthread.php?t=125165
elseif(
$week==2) {include('AllStars2005w2.php');}
elseif(
$week==3) {include('AllStars2005w3.php');} 
etc etc etc.

Hope this helps.

Happy coding.

-Bob
__________________
Can't wait to be out of this forsaken business. Getting close! :)
moondog is offline  
Old 09-20-2005, 07:49 AM   #4 (permalink)
NamePros Regular
Join Date: Aug 2005
Posts: 214
slantednet is on a distinguished road
 



Example:
PHP Code:
if($week==1) {include('AllStars2005w1.php');}
elseif(
$week==2) {include('AllStars2005w2.php');}
elseif(
$week==3) {include('AllStars2005w3.php');} 
????: NamePros.com http://www.namepros.com/showthread.php?t=125165
Or you can:
PHP Code:
$incpage "AllStars2005w" $week ".php";
include(
$incpage); 
To take care of all the weeks...

Mike
Or
__________________
OnlineGames.net
slantednet is offline  
Old 09-20-2005, 08:50 AM   #5 (permalink)
NamePros Regular
 
moondog's Avatar
Join Date: Jun 2004
Posts: 587
moondog is a name known to allmoondog is a name known to allmoondog is a name known to allmoondog is a name known to allmoondog is a name known to allmoondog is a name known to allmoondog is a name known to allmoondog is a name known to all
 



Originally Posted by slantednet
Or you can:
PHP Code:
$incpage "AllStars2005w" $week ".php";
????: NamePros.com http://www.namepros.com/showthread.php?t=125165
include(
$incpage); 
That works too.

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! :)
moondog is offline  
Old 09-21-2005, 06:40 AM THREAD STARTER               #6 (permalink)
NamePros Member
Join Date: Mar 2005
Posts: 36
FreeBaGeL is an unknown quantity at this point
 



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.
FreeBaGeL is offline  
Closed Thread


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

Liquid Web Smart Servers  
All times are GMT -7. The time now is 07:42 AM.

Managed Web Hosting by Liquid Web
Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger