Jump to content

Archived

This topic is now archived and is closed to further replies.

bagnallc

mysql search

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>"; }
?>

Share this post


Link to post
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]

Share this post


Link to post
Share on other sites
thanks for reply. i did actually try that but it still hung.

i have just changed my form to a dropdown box and its an immediate response now! i dont really understand why but once it works im happy!

thanks again for your advice though

Share this post


Link to post
Share on other sites

×

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.