Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.
Moderator: General Moderators
palmere
Forum Newbie
Posts: 17 Joined: Fri Mar 19, 2004 5:33 pm
Post
by palmere » Fri Mar 19, 2004 5:33 pm
Hey guys, I'm a complete newbie to this forum and somewhat of a newbie to php all together. I'm wondering (and I'm sure there is) some easy way to display all the entries that BEGIN with a specific letter.
In my case, I have a database that has artist names in it, and I want to be able to create a dynamic page that lists all artists that begin with a, b, and so on.
Thanks much.
timvw
DevNet Master
Posts: 4897 Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium
Post
by timvw » Fri Mar 19, 2004 5:46 pm
2 ways:
Make use of like and %
Make use of substring
Illusionist
Forum Regular
Posts: 903 Joined: Mon Jan 12, 2004 9:32 pm
Post
by Illusionist » Fri Mar 19, 2004 5:56 pm
Code: Select all
$letter = "a";
$sql = "SELECT name FROM Artists WHERE name LIKE '$letter%'";
palmere
Forum Newbie
Posts: 17 Joined: Fri Mar 19, 2004 5:33 pm
Post
by palmere » Wed Apr 07, 2004 5:05 pm
Well, I posted this question a long time ago before I left on vacation expecting that someone would eventually get back to me...
little did i know that there would be 2 replies in a couple minutes of my post. Thanks a ton guys. Got it figured out.
E
patrikG
DevNet Master
Posts: 4235 Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK
Post
by patrikG » Wed Apr 07, 2004 5:24 pm
Good holiday then, I hope?
palmere
Forum Newbie
Posts: 17 Joined: Fri Mar 19, 2004 5:33 pm
Post
by palmere » Wed Apr 07, 2004 5:44 pm
Heck yeah,
With skiing in Colorado, gambling and Vegas and camping in Utah, you can't go wrong.
E
tim
DevNet Resident
Posts: 1165 Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio
Post
by tim » Wed Apr 07, 2004 7:02 pm
eeeeh
last time I went skiing, I ended up with a sore buttox.
last time I went camping I didnt catch any fish, when my buddies caught the mininum of 4
grr! lol... Fun though none the less
patrikG
DevNet Master
Posts: 4235 Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK
Post
by patrikG » Thu Apr 08, 2004 2:45 am
You must be grateful you haven't been gambling, tim
tim
DevNet Resident
Posts: 1165 Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio
Post
by tim » Thu Apr 08, 2004 4:26 pm
patrikG wrote: You must be grateful you haven't been gambling, tim
On the contrary, i been known to wipe out some peoples pockets when it comes to the ole poker ride. Hence why i'm usually not welcomed to play =]