I have been using php for my design, Buy i wouldn't, creating dymanic url is a problem for me. Now I need it and urgently. Please guy I need your help. Example: http://www.daniweb.com/forums/newthread.php?do=newthread&f=17

Recommended Answers

All 5 Replies

index.php

<?php
if($_GET['id'] == 1){
echo 'page 1';
}elseif($_GET['id'] == 5){
echo 'contact page';
}else{
echo 'page 2';
}
?>

---------------------------------
index.php?id=1 -> page 1
index.php -> page 2
index.php?id=5 -> contact page

Thanks very much man, Can you make it simpler by coding example?

That was an example, its generally backed by a database and each page is generated by putting data from it in a template. you could do like above but it is probably easier just making new pages as it will get quite bloated.

includes may help keep the file small

index.php
 
<?php
if($_GET['id'] == 1){
require_once 'aboutus.html';
}elseif($_GET['id'] == 5){
require_once 'contact';
}else{
require_once 'home.html';
}
?>

if you have a mysql database/server available look at learning how to make use of that to make best use of dynamic pages

http://www.freewebmasterhelp.com/tutorials/phpmysql

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.