问题描述:

Basically what I'm wanting to do is make it to where when a visitor comes to our site and clicks on one of the links within the drop-down menu, it searches for a keyword within our database.

How can this be done?

Find below our php script for the search engine:

 <!-- SEARCH RESULTS -->

<div class="results">

<?php

error_reporting(0);

if (isset ($_POST['search']) && !empty($_POST['search']))

{

$search = htmlspecialchars($_POST['search']);

//load database connection

$host = "localhost";

$user = "jaguartr_logins";

$password = "Pow!!62";

$database_name = "jaguartr_Cookies";

$pdo = new PDO("mysql:host=$host;dbname=$database_name", $user, $password, array(

PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION

));

// Search from MySQL database table

//tables are : ID, DATE, SERVICE, TYPE, DATA

$query = $pdo->prepare("SELECT * FROM Cookie WHERE DATE LIKE '%$search%' OR SERVICE like '%$search%' ORDER BY ID DESC LIMIT 0,25");

$query->bindValue(1, "%$search%", PDO::PARAM_STR);

$query->execute();

// Display search result

if (!$query->rowCount() == 0)

{

echo "<span style=\"padding-left:15px;padding-top:50px;color:#7d869e;\">Results ...</span><br/><br/>";

echo "<table style=\"font-family:myFirstFont;font-size:22px;\">";

//echo "<tr><td>Date</td><td>Service</td><td>Type</td><td>Data</td></tr>";

while ($results = $query->fetch())

{

echo "<tr>";

echo "<td style='width:240px; text-align:left;'>";

echo $results['DATE'];

echo "</td>";

echo "<td style='width:240px; text-align:center;'>";

echo $results['SERVICE'];

echo "</td>";

echo "<td style='width:240px; text-align:center;'>";

echo $results['TYPE'];

echo "</td>";

echo "<td style='text-align:right;'>";

//echo $results['LINK'];

$AccessLink = false;

if ((http_check($results['DATA'])) and ($results['TYPE'] == "Cookie"))

{

$result = file_get_contents($results['DATA']);

}

if ((http_check($results['DATA'])) and ($results['TYPE'] == "AutoLogin"))

{

$result = $results['DATA'];

$AccessLink = true;

}

else

{

$result = $results['DATA'];

}

if ($AccessLink)

{

echo '<a class="get" href="ads.php?url='.base64_encode($result).'" target=\"_blank\">GET MY LOGIN!</a>';

}

else

{

echo "<div id=\"modal-container\">

<div class=\"modal-background\">

<div class=\"modal\">

<h2 style=\"color:#000\">".$results['TYPE']."</h2>

<p style=\"color:#000\">".$result."</p>

</div>

</div>

</div>";

echo "<a href=\"#\" id=\"five ".$results['ID']."\" class=\"button\">Show ".$results['TYPE']."</a>";

//echo "<a href=\"javascript:mod('#link".$results['ID']."');\">Show ".$results['TYPE']."</a>";

//echo "<div id=\"link".$results['ID']."\" style=\"display:none;\">";

//echo "<p class=\"modeling\">".$result."</p>";

}

echo "</div>";

echo "</td>";

echo "</tr>";

}

echo "</table>";

}

else

{

echo "<div style=\"margin:0 auto;height:250px;\"></div>";

echo '<span style=\"font-family:"myFirstFont";font-size:24px;color:#7f7fe5;\">NO RESULTS.. TYPE IN SOMETHING ELSE..</span>';

echo "<div style=\"margin:0 auto;height:250px;\"></div>";

}

}

else

{

// :P type here something or leave it blank

echo "";

}

?>

</div>

<!-- /SEARCH RESULTS -->

相关阅读:
Top