Jump to content

Recommended Posts

hi

when i run the following query on mysql database it is very fast (immediate)

SELECT id, name from names WHERE MATCH(name) AGAINST ('whatever*' IN BOOLEAN MODE)

but when i use it in a page with php it is hanging (although does eventually return as expected)

is there a better way of writing the code?

here is code

<?php
require("connectmysql.php");
$search=$_GET["name"];
$data= "%".$search."%";
if(isset($search)) {
$qry= mysql_query("SELECT id, name from names WHERE MATCH(name) AGAINST ('$search*' IN BOOLEAN MODE)"); }

if (isset($qry)) { echo "Here are the results:<br><br>"; echo "<form>";
echo "<table align=center border=1><tr><th align=center bgcolor=#00FFFF></th></tr>";
while($checkbox=mysql_fetch_array($qry)) {
echo "<tr><td><input type='checkbox' name='name[]' value=$checkbox[id]>" . " " . $checkbox[name] . "</td></tr>" ; }
echo "</table><input type='submit' value='GO!'></form>"; }
?>
Link to comment
https://forums.phpfreaks.com/topic/13598-mysql-search/
Share on other sites

You could try a simple query instead of a fulltext search

[code]<?php
require("connectmysql.php");
if(isset($_GET['name'])) {
  $search=$_GET["name"];

  $qry= mysql_query("SELECT id, name from names WHERE name LIKE '%$search%' ");


}
?>[/code]
Link to comment
https://forums.phpfreaks.com/topic/13598-mysql-search/#findComment-52704
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.

Guest
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.