我对营地来说很陌生,我正在开发一个有搜索条的网站。
我已使用一些代码进行查询,以从我的数据库中寻找产品。 搜查令进行罚款,显示需要展示的所有所需产品。
然而,我希望这些物品与产品详细页有链接,显示有关这一具体产品的更多信息。 然而,我没有你如何把这一点作为使用html的链接。
My search code is as follows:
<?php
error_reporting(E_ALL);
ini_set( display_errors , 1 );
$search_output = "";
if(isset($_POST[ searchquery ]) && $_POST[ searchquery ] != ""){
$searchquery = preg_replace( #[^a-z 0-9?]#i , , $_POST[ searchquery ]);
if($_POST[ filter1 ] == "Food"){
$sqlCommand = "SELECT * FROM tbl_product WHERE pd_name LIKE %$searchquery% ";
}
include_once("config.php");
//Database connections below
mysql_connect($dbHost, $dbUser, $dbPass) or die(mysql_error());
mysql_select_db($dbName) or die(mysql_error());
$query = mysql_query($sqlCommand) or die(mysql_error());
$count = mysql_num_rows($query);
if($count >= 1){
$search_output .= "<hr />$count results for <strong>$searchquery</strong><hr />";
while($row = mysql_fetch_array($query))
{
$pd_name = $row["pd_name"];
$search_output .= "$pd_name<br />";
} // close while
} else {
$search_output = "<hr />0 results for <strong>$searchquery</strong><hr />";
}
}
?>
<html>
<head>
</head>
<body>
<form action="<?php echo $_SERVER[ PHP_SELF ]; ?>" method="post">
Search for dishes :
<input name="searchquery" type="text" size="30" maxlength="100">
In:
<select name="filter1">
<option value="Food">Food</option>
</select>
<input name="myBtn" type="submit" value="Search">
<br />
</form>
<div>
<?php echo $search_output; ?>
</div>
</body>
</html>
我想提及的是:
<a href="" . $_SERVER[ PHP_SELF ] . "?c=$catId&p=$pd_id" . "">$pd_name</a>
However, when adding this reference, it does not seem to work. Any help would be appreciated. Thanks in advance.