我正在使用教程来创建搜索引擎。我有它来做搜索。但现在我试图让它将用户点击的链接和他们使用的搜索查询插入另一个数据库表。我很难做到这一点。
我在这里看到
include_once ('database_connection.php');//Including our DB Connection file
if(isset($_GET['keyword'])){//IF the url contains the parameter "keyword"
$keyword = trim($_GET['keyword']) ;//Remove any extra space
$keyword = mysqli_real_escape_string($dbc, $keyword);//Some validation
$query = "select topictitle,topicdescription from topics where topictitle like '%$keyword%' or topicdescription like '%$keyword%'";
//The SQL Query that will search for the word typed by the user .
$result = mysqli_query($dbc,$query);//Run the Query
if($result){//If query successfull
if(mysqli_affected_rows($dbc)!=0){//and if atleast one record is found
while($row = mysqli_fetch_array($result,MYSQLI_ASSOC)){ //Display the record
$image = '';
switch( $row['Carrier'] ) {
case 'Nextel(Sprint)':
$image = './images/rat.png';
break;
case 'Verizon':
$image = './images/dog.png';
break;
case 'Sprint':
$image = './images/rooster.png';
break;
case 'AT&T(also Cingular)':
$image = './images/ox.png';
break;
case 'T-Mobile':
$image = './images/snake.png';
break;
case 'Tiger':
$image = './images/tiger';
break;
}
echo '<table><tr><td>We Think your Number is </td><td><a href="next.php?csv='.$row['Carrier'].'">
<img src="'.$image.'" alt="'.$row['Carrier'].'" title="'.$row['Carrier'].'" /></a></td><td> Is that correct? <a href="">Yes</a> Or
<a href="#" id="button" class="button_style">No</a></td></tr></table>
<div id="hidden_content">
<ul><!-- IF user clicks one of these links it will direct them to the page then insert there search query and the link they clicked into a database
<li><a href="next.php?rat"><img src="./images/rat.png" /></a></li>
<li><a href="next.php?dog"><img src="./images/dog.png" /></a></li>
<li><a href="next.php?rooster"><img src="./images/rooster.png" /></a></li>
<li><a href="next.php?ox"><img src="./images/ox.png" /></a></li>
<li><a href="next.php?snake"><img src="./images/snake.png" /></a></li>
<li><a href="next.php?tiger"><img src="./images/tiger.png" /></a></li>
</ul>
</div>';
}
}else {
echo 'No Results for :"'.$_GET['keyword'].'"';//No Match found in the Database
}
}
}else {
echo 'Parameter Missing in the URL';//If URL is invalid
}
我的问题是我正在尝试获取它,因此当用户单击链接时,该链接被单击并插入数据库以及用户键入的查询。但我不知道该怎么做