trimming text for a query, and making it efficient
Posted: Sun Aug 21, 2005 8:12 am
There's more to it than the title.
Basically I have a list in my database, it's a client list. It's growing rapidly and in order to make more sense of it I've created (am creating) a way to click A-Z and get back all clients whose name starts with whatever you click.
ie: click on 'S' and all clients whose name starts with S comes back in the list.
I was going to do it this way, but I think it's not efficient:
all well and good, but I'd rather trim the fat in the SQL query if it can be done... can it be done or is that it, searching through the WHOLE database in a loop?!
Thanks for your time
Rob
Basically I have a list in my database, it's a client list. It's growing rapidly and in order to make more sense of it I've created (am creating) a way to click A-Z and get back all clients whose name starts with whatever you click.
ie: click on 'S' and all clients whose name starts with S comes back in the list.
I was going to do it this way, but I think it's not efficient:
Code: Select all
$letter = $_GET['letter'];
loop thru database.
{
if ($string{0} == $letter) //using substring to find first letter
{
show the name
}
}Thanks for your time
Rob