Trying to figure out what something is called

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Glass Casket
Forum Newbie
Posts: 6
Joined: Thu Oct 13, 2005 10:22 am

Trying to figure out what something is called

Post by Glass Casket »

I'm simply trying to figure out what it's called when you do $letter=d, &letter=a, and so on. And it only retrieves the rows from the database that start with that letter. I'm trying to find out how to do it, but can't find a tutorial.

Thanks!
User avatar
Jenk
DevNet Master
Posts: 3587
Joined: Mon Sep 19, 2005 6:24 am
Location: London

Post by Jenk »

wuh?
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Code: Select all

$letter = 'd';

$query = "SELECT field_name FROM table_name WHERE some_field LIKE '{$letter}%'";
Not sure what you mean what it's called? Searching/sorting? :)
Glass Casket
Forum Newbie
Posts: 6
Joined: Thu Oct 13, 2005 10:22 am

Post by Glass Casket »

Thanks, after reading that and palying with it I figured some of it out. But I can't seem to figure out how to query all the rows begining with a letter at the same time. Instead of having a query for each letter.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

use the REGEXP command..
Glass Casket
Forum Newbie
Posts: 6
Joined: Thu Oct 13, 2005 10:22 am

Post by Glass Casket »

feyd wrote:use the REGEXP command..
Thank you, that worked!
Post Reply