Hi chuck,
use left()
assuming your column is called name, then something like this will do:
$letter = a;
$get = @mysql_query(SELECT * FROM table WHERE LEFT(surname, 1) = '$letter'
ORDER BY surname ASC);
That should get out all of the fields beginning with a or A and list them
alphabetically.
An option too:
SELECT * FROM table WHERE SURNAME LIKE 'a%' ORDER BY surname ASC
Niklas
-Original Message-
From: liljim [mailto:[EMAIL PROTECTED]]
Sent: 11. maaliskuuta 2002 11:09
To: [EMAIL PROTECTED]
Subject: Re: [PHP] Re: A stupid question...
Hi chuck,
use left()
assuming your
--
From: Chuck PUP Payne [SMTP:[EMAIL PROTECTED]]
Sent: 11 March 2002 02:59
To: Cary; mysql lists.mysql.com
Cc: PHP General
Subject: Re: [PHP] Re: A stupid question...
I want to sort my a letter in a set colomn. Let say I want
Ok, I have tried this but no luck...I have included the page I have been
working on. I have it list everything now but last name.
# This what I want to change so that I can do it by letter #
$result =mysql_query(SELECT * FROM emply_info ORDER BY Lname, Fname
DESC,$db);
I have tried everything
What do you mean it doesn't like the LIKE
Please provide the query statement you used and the response from the
application
-Original Message-
From: Chuck PUP Payne [mailto:[EMAIL PROTECTED]]
Sent: Monday, March 11, 2002 4:22 PM
To: liljim
Cc: PHP General
Subject: Re: [PHP] Re
General
Subject: RE: [PHP] Re: A stupid question...
What do you mean it doesn't like the LIKE
Please provide the query statement you used and the response from the
application
-Original Message-
From: Chuck PUP Payne [mailto:[EMAIL PROTECTED]]
Sent: Monday, March 11, 2002 4:22 PM
To: liljim
didn't like about your query
-Original Message-
From: Chuck PUP Payne [mailto:[EMAIL PROTECTED]]
Sent: Monday, March 11, 2002 4:31 PM
To: Rick Emery; 'Chuck PUP Payne'; liljim
Cc: PHP General
Subject: RE: [PHP] Re: A stupid question...
$result =mysql_query(SELECT * FROM emply_info WHERE
I just noticed your WHERE clause is incomplete.
-Original Message-
From: Rick Emery [mailto:[EMAIL PROTECTED]]
Sent: Monday, March 11, 2002 4:33 PM
To: 'Chuck PUP Payne'
Cc: PHP General
Subject: RE: [PHP] Re: A stupid question...
To help you diagnose the problem, I suggest:
$query
You're using the wildcard in the wrong place.
Should be
like '$letter%';
Or,
left(column, 1) = '$letter';
use a die() and mysql_error() to report problems to the browser:
$result =mysql_query(SELECT * FROM emply_info WHERE LEFT(Lname, 1) =
'$letter' ORDER BY Lname, Fname DESC,$db)
or
PUP Payne [mailto:[EMAIL PROTECTED]]
Sent: Monday, March 11, 2002 4:31 PM
To: Rick Emery; 'Chuck PUP Payne'; liljim
Cc: PHP General
Subject: RE: [PHP] Re: A stupid question...
$result =mysql_query(SELECT * FROM emply_info WHERE Lname ORDER BY Lname,
Fname
DESC LIKE'%$letter',$db);
$letter=a
That's
I want to sort my a letter in a set colomn. Let say I want to sort the
colomn last_name
http://www.myserver.com/mysort.php?Letter=A
Like to create a link like A then sort only the last name ore what ever I
want to sort by that letter.
I hope that's helps. I can order by, but I can't so a sort
I want to sort by a letter in a colomn. Let say I want to sort the colomn
last_name. I can do order by but I can do just the A's.
http://www.myserver.com/mysort.php?Letter=A
Like to create a link on a web A then sort only the last name are A.
I hope that's helps. I can order by, but I can't
Chuck Pup Payne wrote:
I want to sort by a letter in a colomn. Let say I want to sort the colomn
last_name. I can do order by but I can do just the A's.
http://www.myserver.com/mysort.php?Letter=A
Like to create a link on a web A then sort only the last name are A.
I hope that's
: [PHP] Re: A stupid question...
I want to sort by a letter in a colomn. Let say I want to sort the
colomn
last_name. I can do order by but I can do just the A's.
http://www.myserver.com/mysort.php?Letter=A
Like to create a link on a web A then sort only the last name are A.
I hope that's helps
14 matches
Mail list logo