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 2 of 2
  1. #1
    New Coder
    Join Date
    Feb 2005
    Posts
    29
    Thanks
    0
    Thanked 0 Times in 0 Posts

    question regarding sql with php

    Code:
    $name = $_POST['p_name'];
    
    if (!empty($name)) { 
    $result = "select * from product where name LIKE '$name'";
    }
    What I need is when the user types something like c* in the edit box, it will return all records where the product Name begins with c..

    At the moment, I have it like if I enter c% in the edit box, then it will returns records where the name begins with c. BUT I don't want this, I need it to be so the user enters <letter*> (e.g. a*) and then it processes the query to return all recrds where name begins with <letter>

    So, what im stuck on is how to get the input, e.g. c*, to something like
    select * from product where name LIKE 'c%'
    ..thanks in advance.

  • #2
    New Coder
    Join Date
    Feb 2005
    Posts
    29
    Thanks
    0
    Thanked 0 Times in 0 Posts
    No need for an answer, Fou-lo helped me in the php section.


  •  

    Posting Permissions

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