Dynamic Link Creation

Dynamic Link

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<?php $con = mysql_connect("localhost","root","");
mysql_select_db("123", $con);  $result = mysql_query("SELECT * FROM asd");
echo "<table border='1'> <tr> <th>Name</th> <th>Roll</th> </tr>";
while($row = mysql_fetch_array($result))
  {
  echo "<td>".$row['name']."</td>";
  echo "<td>" . $row['roll'] . "</td>";
  echo "<td><a href=\"view.php?id=".$row['id']."\">View</a>";
  echo "</tr>";   } echo "</table>";
  mysql_close($con); ?>
</body>
</html>

Dynamic Page Result:


<<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<HTML>
<?php
$id=$_GET['id'];
$db = mysql_connect("localhost", "root", "");
mysql_select_db("123",$db);
$result = mysql_query("SELECT * FROM asd WHERE id=$id",$db);
$row = mysql_fetch_array($result);
echo "Name: ".$row["name"];
echo "<br>Roll: ".$row["roll"];
?>
</HTML>
</body>
</html>



No comments:

Post a Comment