Hi all.. I am new in php and mysql, I have a question: I have an home page, there are three links : news1, new2 and news3. and then I have one page to display the news, display.php. Can I display news1,news2,news3 in display.php. So I dont need to make 3 different page (display1.php, display2.php, display3.php) to display 3 different content (news1, new2 and news3) I want to make it dynamic. many thanks
yep, one way is, it is done by declaring a parameter. u must have a "container" using css where you will put all those links.. and then call for the parameters.. <a href="display.php?parameter=1">news1</a> <a href="display.php?parameter=2">news2</a> <a href="display.php?parameter=3">news3</a> for example: display.php <a href="display.php?parameter=1">news1</a> <a href="display.php?parameter=2">news1</a> <a href="display.php?parameter=3">news1</a> $parameter = $_GET['parameter']; switch($parameter) // switch statement is under the container { case 1: include("news1.php"); break; case 2: include("news2.php"); break; case 3: include("news3.php"); break; } PHP: hope this help..
i think, that bartolay13's code not safety... $default = 1; $url[1]="news1.php"; $url[2]="news2.php"; $url[3]="news3.php"; if(isset($_GET["page"])) { $page=intval($_GET["page"]); if($page<1 or $page>count($url)) $page=1; if(@$url[$page]=='') $page=1; include($url[$page]); } include($url[$default]); Code (markup):