Url rewriting: there are two type urls according to my knowledge.one is absolute url and other is relative url.in absolute url we are define the path of server in a variable.(.htaccess file,absolute url,mod rewriting in .htaccess)
Step 1: Create a config file for database connectivity (config.php)
<?php
mysql_connect("localhost","username","password");
mysql_select_db("database_name");
$path="http://yourdomainname.com";
?>
Step 2:now cteate a php link file
<!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=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
include("config.php");
<?php
$rs=mysql_query("select * from table_name");
while($row=mysql_fetch_array($rs)) { ?>
<a href="<?php echo $path."/search/".$row["name"]."-".$row["id"]; ?>"><?php echo $row["name"]; ?></a>
<?php }
?>
</body>
</html>
Step 3: Create a .htaccess file
Options +FollowSymLinks
RewriteEngine on
RewriteBase /
RewriteRule ^search/(.*)-([0-9]+)$ search.php?name=$1&id=$2 [NC,L]
Step 4:now use this data into search.php page
<?php
echo $_GET["name"];
echo $_GET["id"];
?>
No comments:
Post a Comment