Hi I wondering if its posible to create an if statement that will change HTML content based on the page. That it will show one thing for the index page and one thing for other pages eg if page =="index" (html code) else (other html) thanks
say the following is a file named index.php <?php $page=$_GET['p']; if($page==1){ ?> [first page's html...] <?php } elseif($page==2){ ?> [second page's html...] <?php } elseif($page==3){ ?> [third page's html...] <?php } . . . elseif($page==99){ ?> [last page's html...] <?php } else{ ?> [index's html...] <?php } ?> PHP: then you can access each page using the following format: http://domain.com/index.php?p=1 http://domain.com/index.php?p=2 ... http://domain.com/index.php?p=99 obviously you need to change the [html for page X] part with the content you want to show for each page. also it's worth mentioning that you're not limited to numbers for the page names. but if you want to use something else you must put it in " " when placing it in the if statement: if($page="firstpage"){ ... } PHP: also it's better if you don't use space or any character like &, # and such and stick to the alphabet, numbers and use "_" to separator words if needed: http://domain.com/index.php?p=firstpage or http://domain.com/index.php?p=first_page
Ok thanks I just need it show one of two pieces of code one for the index and one for all the other pages so what do i call the index page <?php $page=$_GET['p']; if($page==1){ ?> [first page's html...] <?php PHP: can I just say if($page==index.php){ PHP: or i f($page==domainname.com){ PHP:
the last part is the index: else{ ?> [index's html...] <?php } ?> PHP: say you have 3 pages (index+2) and you want to name them, this is how: <?php $page=$_GET['p']; if($page=="second_page"){ ?> [second_page's html...] <?php } elseif($page=="contact"){ ?> [contact page's html...] <?php } else{ ?> [index's html...] <?php } ?> PHP: these are accessible through the following URLs: index: domain.com OR domain.com/index.php second_page: domain.com/index.php?p=second_page OR domain.com/?p=second_page contact: domain.com/index.php?p=contact OR domain.com/?p=contact