SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Guru
    Join Date
    Dec 2005
    Posts
    964
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Search/compare only 3 first letters?!?

    I have a search call into my db like this:
    PHP Code:
    $sql "SELECT coursename FROM ".$prefix."_courses WHERE coursename LIKE '%" $course "%' AND country='$ccountry' AND state='$cstate'"
    Now this compares all written in my searchfield, but how can only make it compare the first 3 letters?

    Thanks in advance.

  2. #2
    SitePoint Guru
    Join Date
    Dec 2005
    Posts
    964
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry... Found a soulution!
    PHP Code:
    $coursesearch substr($course03); 

  3. #3
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    <?php
    $sql 
    "SELECT something FROM table WHERE foo LIKE '" substr('bacon'03) . "%'";
    echo 
    $sql#SELECT something FROM table WHERE foo LIKE 'bac%'
    ?>
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.


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
  •