Jump to content

Mysqli, php - MATCH AGAINST for searching.


Recommended Posts


I'm trying to create a script which searchs through several columns in a table, using a keyword to search. I use mysqli and a query with MATCH AGAINST. I have got a code but it does not work and I do not know why. It does not give any error, but it basicly returns nothing. Here is my code:


if (isset($_POST['submit'])) {
    $tag = $_POST['tag'];
    $query = ("SELECT Tutorialid, Title, Author FROM tutorials  WHERE MATCH (Title, Body1, Body2, Body3, Body4, Author) AGAINST (?)");      
   if ($stmt = $connection->prepare($query)){


$stmt->bind_result($id, $title, $author);

$html_table = '</br></br><table class="cats" cellpadding="10" cellspacing="0">

             <th class="cath">Title</th>
             <th class="cath">Author</th>
<th class="cath">Link</th>  

while ($stmt->fetch())

$link = "<a href='http://everytutorial.net/tutorials/".$id."'>Click here to open</a>";

$html_table .= '<tr><td class="catd">' .$title. '</td><td class="catd">' .$author.'</td><td class="catd">'.$link.'</td></tr>';

$html_table .='</table></br></br></br>';

if (empty($id))
 echo "<p>No tutorials found milord.</p>";
 else {
echo $html_table;



I'm not sure what's wrong with it - any help could be great, thanks!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.