Created
February 11, 2017 18:20
-
-
Save larikraun/68847e9352f9f3c2ba821852ca591e11 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
mysql_connect("localhost", "root", "yourpassword"); | |
mysql_select_db("test"); | |
require_once('sphinxapi.php'); | |
$s = new SphinxClient; | |
$s->setServer("127.0.0.1", 9312); // NOT "localhost" under Windows 7! | |
$s->setMatchMode(SPH_MATCH_ANY); | |
$s->SetLimits(0, 25); | |
$q=$_GET["q"]; | |
$result = $s->Query($q); | |
if ($result['total'] > 0) { | |
echo 'Total: ' . $result['total'] . "<br>\n"; | |
echo 'Total Found: ' . $result['total_found'] . "<br>\n"; | |
echo '<table>'; | |
echo '<tr><td>No.</td><td>ID</td><td>Group ID</td><td>Group ID 2</td><td>Date Added</td><td>Title</td><td>Content</td></tr>'; | |
foreach ($result['matches'] as $id => $otherStuff) { | |
$row = mysql_fetch_array(mysql_query("select * from documents where id = $id")); | |
extract($row); | |
++ $no; | |
echo "<tr><td>$no</td><td>$id</td><td>$group_id</td><td>$group_id2</td><td>$date_added</td><td>$title</td><td>$content</td></tr>"; | |
} | |
echo '</table>'; | |
} else { | |
print $s->GetLastError(); | |
echo 'No results found'; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment