Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require_once('/tmp/sphinx-2.2.10-release/api/sphinxapi.php');
- $searchterm = htmlspecialchars($_GET['suche']);
- //Sphinx-Search
- $cl = new SphinxClient();
- $cl->SetServer("localhost", 9312);
- $cl->SetMatchMode(SPH_MATCH_ANY);
- $result = $cl->Query($searchterm, 'music');
- if ( ! empty($result["matches"])) {
- foreach ( $result["matches"] as $key => $value)
- {
- $servername = "localhost";
- $username = "root";
- $pass = "Musik4live!";
- $dbname = "sphinx-music";
- $conn = new mysqli ($servername, $username, $pass, $dbname);
- if ($conn->connect_error)
- {
- die ("Connection failed: " . $conn->connect_error);
- }
- $sql = "SELECT music_id, title, interpret, year FROM music WHERE music_id = $key";
- $result2 = $conn->query($sql);
- if($result2->num_rows > 0)
- {
- while ($row = $result2->fetch_assoc())
- {
- echo "<br>id: ". $row["music_id"]. " - Title: " .$row["title"] . " - Interpret: ". $row['interpret']. "<br>";
- }
- }
- else
- {
- echo " 0 results";
- }
- $conn->close();
- }
- }
- exit;
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement