我有以下文件:如何將搜索結果中特定成分會進入另一個頁面
file1.php:包括搜索表單:
<form action="search.php" method="GET">
<input type="text" name="query" />
<input type="Submit" value="Search" />
</form>
和 文件2「的search.php」是提交結果的文件:
<?php
require "../session.php";
$query = isset($_GET['query']) ? $_GET['query'] : "";
$raw_results = mysql_query("SELECT * FROM Component WHERE (`ComName` LIKE '%".$query."%')") or die(mysql_error());
$number = mysql_num_rows($raw_results);
if(mysql_num_rows($raw_results) > 0){
$i=1;
echo "<p><h3>" ."There are (<font color='red'>".$number ." </font>) matches to your search of" ."<font color='red'> $query </font>" ."</h3></p>"
while($results = mysql_fetch_array($raw_results)) {
$_SESSION['ComName']= $results['ComName'];
print_r ("<p><h3>" ."<font color=yellow>" ." " .$i."- </font>" ."<a href=\"ViewComponents.php?flag=Submit&status_Component=".$_SESSION['ComName']."\">" . str_ireplace($query, "<font color=red>$query</font>", $_SESSION['ComName']) .'</font>'."</h3>" ."</a>";
$i++;
} else{
echo "<p><h3>" ."Sorry there are no results for your search of " ."<font color='red'> $query</font>." ."</h3></p>";
}
}
?>
問題是當我從搜索結果頁面(如component2)點擊特定組件時;這應該傳遞到file3「ViewComponents.php」,但文件「ViewComponents.php只顯示搜索結果中的最後一個組件會話,而不是點擊組件
如何使點擊的組件傳遞給其他文件」ViewComponents .php「而不是僅傳遞最後一個組件?
你可以在這裏發佈「ViewComponents.php」文件中負責查看組件的部分嗎? 您應該避免使用mysql_ *函數,因爲它們已被棄用並從PHP 7中刪除。 – Alfasatwi
代碼是使用php5編寫的。部分文件「ViewComponents.php」是:<?php $ temp_package = $ _ SESSION ['ComName']; $ sql =「SELECT ProductName FROM組件其中ComName ='$ temp_package'ORDER BY ProductName ASC」; $ result = mysql_query($ sql); $ number = mysql_num_rows($ result); echo「
注意:我們的記錄顯示有(」。$ number。「)產品版本包含$ temp_package。 ?>
<? – Louie