Reply
Navigation and content display
Old 10-31-2005, 12:30 PM Navigation and content display
Skilled Talker

Posts: 60
Hi there,

I am fairly new to web design and I wondered if anyone could explain how people use the query string in the url of one page to show different content depending on what link is clicked.

i.e. usually like www.example.php/index.php?content=signup

I understand partly how this works but not how the parameters/variables content and signup would be defined...

would content be a cell in a table? would signup be a page displayed in this cell when the signup link is clicked?

I would really appreciate if someone could explain this and show me an example of how this is coded - I have looked everywhere!

Many Thanks

Hick
The Hick Man is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
Old 11-01-2005, 12:25 PM
sdcdesign.co.uk's Avatar
Extreme Talker

Posts: 199
Location: High Wycombe, Buckinghamshire, London
It all works through server side code. From your url i'll give you a PHP example...

Code:
<?php

$url = $_GET['content'];

if($url=="signup") {
   echo 'signup code goes here';
}

if($url=="home") {
   echo 'homepage code hoes here';
}

?>
It finds out what the querystring is, then runs a few if statements on the page.


Simple really, google it up to find out more.


Hope this helps
__________________
[ Insert witty, yet highly intelligent signature here ]
sdcdesign.co.uk is offline
Reply With Quote
View Public Profile Visit sdcdesign.co.uk's homepage!
 
Old 11-01-2005, 06:56 PM
Skilled Talker

Posts: 60
Ah i see, thanks very much for that - I understand now.

Much appreciated

Hick Man
The Hick Man is offline
Reply With Quote
View Public Profile
 
Old 11-01-2005, 07:26 PM
sdcdesign.co.uk's Avatar
Extreme Talker

Posts: 199
Location: High Wycombe, Buckinghamshire, London
No problem
__________________
[ Insert witty, yet highly intelligent signature here ]
sdcdesign.co.uk is offline
Reply With Quote
View Public Profile Visit sdcdesign.co.uk's homepage!
 
Old 11-08-2005, 07:27 PM
TrentonD's Avatar
Ultra Talker

Posts: 252
Location: Calgary, Alberta, Canada
Also, here is another way to do it which creates more files, but leaves other bits of code a bit cleaner. Like sdcdesign did, I am making this refer to the example site you showed. Just imagine someone has clicked the link
HTML Code:
<a href="index.php?content=signup">Signup</a>
PHP Code:
<?php
//This code would be on the index page, in the content area.
if(isset($content)){  //This is checking to see if the browser has set the $content variable
include("$content.php"); //If the browser has set the var, it is saying to include the $content.php page, which in your case would be signup.php
}
else{
include(
"home.php");  //If no links have been clicked, it will simply include a home page.
}
?>
The link the person has clicked, sets the variable "$content" to signup. So, when the php code runs, it will include $content.php, being signup.php. This file is then displayed on the index.

This is just another variation, of sdcdesigns code, I hope this doesn't confuse you at all
__________________
Signature Coming Soon! :)
TrentonD is offline
Reply With Quote
View Public Profile Visit TrentonD's homepage!
 
Reply     « Reply to Navigation and content display
 

Thread Tools

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

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




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.13111 seconds with 12 queries