Tags: html php script for click link to load in an other page
Example 1:
index.php
<a href="details.php?t=paris"><button>Paris</button></a>
<a href="details.php?t=nice"><button>Nice</button></a>
<a href="details.php?t=bordeaux"><button>Bordeaux</button></a>
<a href="details.php?t=lyon"><button>Lyon</button></a>
details.php
<?php
if(!empty($_GET["t"]))
{
$t = htmlentities($_GET["t"]);
switch($t)
{
case "paris":
$title = "Detail of $t";
$text = "...";
break;
case "nice":
$title "Detail of $t";
$text = "...";
break;
case "bordeaux":
$title "Detail of $t";
$text = "...";
break;
case "lyon":
$title "Detail of $t";
$text = "...";
break;
default:
$title = "You asked $t, but is an unknown town in our database";
$text = "";
}
}
?>
in head section
<html>
<head>
<?php echo "<title>$title</title>"; ?>
</head>
in body section
<body>
<?php echo "$text"; ?>
</body>
Example 2:
index.php
<html>
<body>
<a href="details.php?t=paris"><button>Paris</button></a>
<a href="details.php?t=nice"><button>Nice</button></a>
<a href="details.php?t=bordeaux"><button>Bordeaux</button></a>
<a href="details.php?t=lyon"><button>Lyon</button></a>
</body>
</html>
details.php
<?php
if(isset($_GET["t"]))
{
if($_GET["t"]=="paris")
{echo "Desc of Paris";}
else if($_GET["t"]=="nice")
{echo "Desc of Nice";}
else if($_GET["t"]=="bordeaux")
{echo "Desc of Bordeaux";}
else if($_GET["t"]=="lyon")
{echo "Desc of Lyon";}
else{echo "Invalid Title!";}
}
else{echo "no get value found!";}
?>
Example 1:
index.php
<a href="details.php?t=paris"><button>Paris</button></a>
<a href="details.php?t=nice"><button>Nice</button></a>
<a href="details.php?t=bordeaux"><button>Bordeaux</button></a>
<a href="details.php?t=lyon"><button>Lyon</button></a>
details.php
<?php
if(!empty($_GET["t"]))
{
$t = htmlentities($_GET["t"]);
switch($t)
{
case "paris":
$title = "Detail of $t";
$text = "...";
break;
case "nice":
$title "Detail of $t";
$text = "...";
break;
case "bordeaux":
$title "Detail of $t";
$text = "...";
break;
case "lyon":
$title "Detail of $t";
$text = "...";
break;
default:
$title = "You asked $t, but is an unknown town in our database";
$text = "";
}
}
?>
in head section
<html>
<head>
<?php echo "<title>$title</title>"; ?>
</head>
in body section
<body>
<?php echo "$text"; ?>
</body>
Example 2:
index.php
<html>
<body>
<a href="details.php?t=paris"><button>Paris</button></a>
<a href="details.php?t=nice"><button>Nice</button></a>
<a href="details.php?t=bordeaux"><button>Bordeaux</button></a>
<a href="details.php?t=lyon"><button>Lyon</button></a>
</body>
</html>
details.php
<?php
if(isset($_GET["t"]))
{
if($_GET["t"]=="paris")
{echo "Desc of Paris";}
else if($_GET["t"]=="nice")
{echo "Desc of Nice";}
else if($_GET["t"]=="bordeaux")
{echo "Desc of Bordeaux";}
else if($_GET["t"]=="lyon")
{echo "Desc of Lyon";}
else{echo "Invalid Title!";}
}
else{echo "no get value found!";}
?>
No comments:
Post a Comment