Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 08-13-2009, 07:32 PM help with php sort
bmcoll3278's Avatar
Super Talker

Posts: 118
Name: Brian Collins
Trades: 0
hey guys here is my query string
mysql_query("SELECT * FROM names WHERE name like '%A%';ORDER BY name ASC");

This Table row contains a single word name My query works but it will pull all names with a (a) in them. Can someone tell me how to match only the first letter of the name so I can display all names with a or b or c you get the idea.

Thanks in advance
__________________
I hope to build a site with something for every one

Please login or register to view this content. Registration is FREE
bmcoll3278 is offline
Reply With Quote
View Public Profile Visit bmcoll3278's homepage!
 
 
Register now for full access!
Old 08-13-2009, 07:43 PM Re: help with php sort
lizciz's Avatar
Super Spam Talker

Posts: 807
Name: Mattias Nordahl
Location: Sweden
Trades: 0
In SQL the % works as a wildcard, so '%A%' will match anything containing an A. To only match words beginning with an A use 'A%' instead.

Also, you should remove the semicolon from the query, since that will otherwise mark the end of the query and the rest (ORDER BY name ASC) will be ignored or attempted to run as a seperate query (probably ignored since your not getting any errors).

So, to sum it up, your query should look like this

SELECT * FROM names WHERE name like 'A%' ORDER BY name ASC
__________________
Your answers will only be as good as your question. Formulate it well and give all the necessary information.

Last edited by lizciz; 08-13-2009 at 07:44 PM.. Reason: Spelling mistake
lizciz is offline
Reply With Quote
View Public Profile Visit lizciz's homepage!
 
Old 08-13-2009, 07:48 PM Re: help with php sort
bmcoll3278's Avatar
Super Talker

Posts: 118
Name: Brian Collins
Trades: 0
Thanks I new it had to be simple But I have been banging my head on the wall for hours.
__________________
I hope to build a site with something for every one

Please login or register to view this content. Registration is FREE
bmcoll3278 is offline
Reply With Quote
View Public Profile Visit bmcoll3278's homepage!
 
Old 08-13-2009, 07:50 PM Re: help with php sort
bmcoll3278's Avatar
Super Talker

Posts: 118
Name: Brian Collins
Trades: 0
The ; was a typo Thanks it gave an error and I removed it.
__________________
I hope to build a site with something for every one

Please login or register to view this content. Registration is FREE
bmcoll3278 is offline
Reply With Quote
View Public Profile Visit bmcoll3278's homepage!
 
Reply     « Reply to help with php sort
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.23505 seconds with 12 queries