Log in

View Full Version : creating first dynamic page



chriskq
08-10-2009, 11:56 PM
i have one php page called states.php

within states.php there are many subpages Eg: states.php?nsw and states.php?qld

how do i create such a page where the content is broken up into sections by php vars.

Regards

traq
08-11-2009, 01:44 AM
http://www.example.com/states.php?page=nsw


<?php

if($_GET['page'] == "nsw"){
// "nsw" content; with the url above, this content is what the user would see
}elseif($_GET['page'] == "qld"){
// "qld" content
}else{
// default content (if there is no valid page id in url)
}

?>


really basic, but that's the idea. They're not variables, but conditional statements based on $_GET information from the url.

chriskq
08-11-2009, 03:52 AM
thanks so much for the reply. no wonder my google search was prooving to be difficult - as i wasnt searching for the right thing.

this easy fix was all i was after.

kind regards traq

traq
08-11-2009, 04:18 AM
no problem. if that's all you need, go back to your first post and click edit > go advanced and set your thread title prefix to "Resolved". glad I could help!