Results 1 to 7 of 7

 

Thread: php and mysql search

  1. #1
    curiouser and curiouser

    Status
    Offline
    Join Date
    Sep 2003
    Location
    uk
    Posts
    659
    Thanks
    1
    Thanked 0 Times in 0 Posts


    I have a php page that searches a database from a form.

    my problem is that the results are a little obscure
    i.e. if i search for car i get results with the word carry in them.

    the search is on a description so I cant have = car.

    any suggestions

    regards andy

  2. #2
    Can't Touch This

    Status
    Offline
    Join Date
    May 2004
    Location
    КРОМИДОВО
    Posts
    321
    Thanks
    3
    Thanked 0 Times in 0 Posts
    if you don't want to, or haven't set up a fulltext index on your description field, try adding spaces to the beginning and the end of the search term;

    WHERE description LIKE '% searchterm %'

    the best method is to create a fulltext index on your description field, then search by a pattern match;

    "SELECT *, MATCH(description) AGAINST ('searchterm') AS score FROM product where MATCH(description) AGAINST ('searchterm') group by score desc"

  3. #3
    curiouser and curiouser

    Status
    Offline
    Join Date
    Sep 2003
    Location
    uk
    Posts
    659
    Thanks
    1
    Thanked 0 Times in 0 Posts
    cheers for that,

    im ashamed to admit it but i use dreamweaver (im currently learning php (im on lesson 4 of sams teach yourself) but i can do so minor editing.

    I currently have:

    "" mysql_select_db($database_sendto, $sendto);
    $query_Recordset1 = sprintf("SELECT * FROM sendto WHERE description LIKE '%%%s%%'", $colname_Recordset1);
    ...................""

    the ........ is query limits etc.

    how would i edit this to use full text search (which is on the column description).

    Kind regards andy

  4. #4
    Can't Touch This

    Status
    Offline
    Join Date
    May 2004
    Location
    КРОМИДОВО
    Posts
    321
    Thanks
    3
    Thanked 0 Times in 0 Posts
    The Query:

    SELECT * FROM sendto WHERE description LIKE '%%%s%%'

    To run it as a fulltext query, you need to replace that SELECT statement with this one:

    SELECT *, MATCH(description) AGAINST ('SEARCHVARIABLE') AS score FROM sendto where MATCH(description) AGAINST ('SEARCHVARIABLE') group by score desc

    SEARCHVARIABLE = Whatever you want it to, a word, or a passed variable.

    Tony

    Dreamweaver is the sharpest tool in my box!

  5. #5
    curiouser and curiouser

    Status
    Offline
    Join Date
    Sep 2003
    Location
    uk
    Posts
    659
    Thanks
    1
    Thanked 0 Times in 0 Posts
    *edit*

    thought i had it sorted but now it seems to only bring the same 19 unrealated results.?


    any ideas

    regards andy
    Last edited by andy_jacko; 13-09-04 at 07:51 AM.

  6. #6
    curiouser and curiouser

    Status
    Offline
    Join Date
    Sep 2003
    Location
    uk
    Posts
    659
    Thanks
    1
    Thanked 0 Times in 0 Posts
    in phpmy admin i have

    "Error
    The additional Features for working with linked Tables have been deactivated. To find out why click here. "

    at the bottom and if i "Click here". i get.

    $cfg['Servers'][$i]['pmadb'] string
    Starting with version 2.3.0 phpMyAdmin offers a lot of features to work with master / foreign - tables. To use those as well as the bookmark feature you need special tables with a predefined structure, which we explain below.
    If you are the only user of this phpMyAdmin installation, you can use your current database to store those special tables; in this case, just put your current database name in $cfg['Servers'][$i]['pmadb'].

    If you are setting up a multi-user phpMyAdmin installation, you will need to create a new database and setup special privileges, so, as superuser:


    create a new database for phpMyAdmin:
    CREATE DATABASE phpmyadmin;
    Note that "controluser" must have SELECT, INSERT, UPDATE and DELETE privileges on this database. Here is a query to set up those privileges (using "phpmyadmin" as the database name, and "pma" as the controluser):
    GRANT SELECT,INSERT,UPDATE,DELETE ON phpmyadmin.* to 'pma'@'localhost';
    do not give any other user rights on this database.
    enter the database name in $cfg['Servers'][$i]['pmadb']


    Im guessing this is a host problem so i contacted them.

    any other suggestions i coul try(im on shared hosting)


    kind regards andy

  7. #7
    Can't Touch This

    Status
    Offline
    Join Date
    May 2004
    Location
    КРОМИДОВО
    Posts
    321
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Andy, without the rest of your query line, I can't tell whats going wrong, if you want to pm me the whole database connection, query and result code, then I can see whats wrong.

    The phpmyadmin stuff isn't relevant for whats happening to this query

    Tony



Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
To Top

Content Relevant URLs by vBSEO 3.5.0 RC2