Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > Beginning PHP
|
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 5th, 2006, 05:40 PM
Registered User
 
Join Date: May 2006
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to nloding Send a message via Yahoo to nloding
Default Using URL for new pages

The subject doesn't quite describe what I want to do. Let me preface this with: I'm absolutely, 100% brand new at PHP -- this is for my first PHP script.

I see a lot of sites having, say, a news article on the main page, and having the URL be something like this:

http://domain.com/index.php?newsid=5

And that loads an entire new main page, with the menu, header, and footer, or what have you, remaining the same of course.

Is there an advantage to doing things this way? Why?

How does that code work? Is there an example code out there??

THANKS!!

--Nathan

 
Old July 7th, 2006, 09:34 AM
Registered User
 
Join Date: May 2006
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to nloding Send a message via Yahoo to nloding
Default

I guess I'll bump this up the forum a bit.

I now see the advantages (less coding by far). But, being new, I'm having a hard time getting the code quite right. Is there a clean example that I can look at somewhere? I've done some googling but haven't found quite what I'm looking for.

 
Old July 10th, 2006, 05:16 PM
Friend of Wrox
 
Join Date: Nov 2005
Posts: 223
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

I'll try to explain the situation with the url.
In this example the file that is requested is index.php.
The variable changes(newsid=1)

The content on the page is partly static wich always has the same values like the layout banner etc.
And partly dynamic. When the newsid varable changes the content changes. The dynamic information can be retrieved externaly like a database.

Ill give you an example

save this file as index.php
Code:
<html>
<head></head>
<body>
<h1>this text is static and remains the same<h1>

<?php 
if (isset($_GET["id"])){
  echo ("this is an dynamic id:<br />".$_GET["id"]); 
}
else{
  echo("now enter index.php?id=1");
}
?>
</body>
<html>
All the dynamic info is generated within the <??> tags
This way you only use one page for more data. This can be effiecent for news pages forums and guestbooks.

if you want to start learning try
w3c schools
__________________________________________________ ________
This is my junk I'm gona eat it





Similar Threads
Thread Thread Starter Forum Replies Last Post
Master Pages, Content Pages and CSS carliviris Visual Studio 2005 0 January 8th, 2008 05:56 PM
URL rewriting with URL forwarding mtabyana BOOK: Professional Search Engine Optimization with PHP: A Dev's Guide to SEO ISBN: 978-0-470-10092-9 0 October 22nd, 2007 08:22 AM
extract URL from Favorites (.URL Files) PhilHawks VB.NET 2002/2003 Basics 2 November 2nd, 2004 04:35 AM
Web pages constructing: I-mode(mobile) pages karib Dreamweaver (all versions) 3 June 6th, 2004 09:48 AM
Hashing of URL while posting web pages debsoft General .NET 1 April 22nd, 2004 09:20 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.