Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Nov 2009
    Posts
    70
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Search by part of string

    Hi

    I trying the search using the query below:

    $result = mysql_query("SELECT * FROM certificado WHERE nome='$name' ") or die (mysql_error());


    If I look for Jose da Silva in table,it only works if I type full name. "Jose da Silva" .

    How can I make the query work by typing part of search string, as "Jose da", "Jose d", etc.

    Moises

  • #2
    Senior Coder
    Join Date
    Jun 2008
    Location
    New Jersey
    Posts
    2,535
    Thanks
    45
    Thanked 259 Times in 256 Posts
    Code:
    SELECT * FROM certificado WHERE nome LIKE '{$name}%'
    LIKE does wildcard search. % means any number of characters. _ could be used for a single character. The search above will find you anything STARTING with the search term. %{$name}% would find anything with the search term in it.

    Also, this is a MySQL issue, not a PHP one.

  • #3
    Banned
    Join Date
    Aug 2013
    Location
    Florianopolis SC
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    php and mysql working together!

    The explanation of Ms. Keleth is really perfect! Congratulations! But I only disagree about "this is a MySQL issue, not a PHP one"

    For people like me that is starting to work with webdesign programm, php and mysql are always working together so de issue that happend with one will make a issue with the other one!


  •  

    Posting Permissions

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