View Full Version : question regarding sql with php

02-27-2005, 02:55 PM
$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.

02-27-2005, 03:21 PM
No need for an answer, Fou-lo helped me in the php section.