To help you diagnose the problem, I suggest: $query = "SELECT * FROM emply_info WHERE Lname ORDER BY Lname, Fname DESC LIKE'%$letter'"; print "$query<BR>\n"; $result =mysql_query("$query) or die("error: ".mysql_error());
This will tell you: (1) whether your query is what you expected (2) what mysql 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 Lname ORDER BY Lname, Fname DESC LIKE'%$letter'",$db); $letter="a" That's what I tried. Chuck -----Original Message----- From: Rick Emery [mailto:[EMAIL PROTECTED]] Sent: Monday, March 11, 2002 5:25 PM To: 'Chuck "PUP" Payne'; liljim Cc: PHP 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 Cc: PHP General Subject: Re: [PHP] Re: A stupid question... 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 and nothing is working, it doesn't like the "LIKE" statement. ----------------------------- | Chuck Payne | | Magi Design and Support | | www.magidesign.com | | [EMAIL PROTECTED] | ----------------------------- ---------------------------------------------------------------------------- <html> <head> <title>Employee Current E-Mail List</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <style type="text/css"> <!-- a:hover { color: #CC0000; text-decoration: underline; font-weight: bold} a:active { color: #990099; text-decoration: none; font-style: oblique} a:link { text-decoration: none} a:visited { color: #FF33FF; text-decoration: none} p { font-family: "Times New Roman", "Times", "serif"; font-size: 6pt; font-style: normal; line-height: normal} normal { font-family: "Times New Roman", "Times", "serif"; font-size: 8pt; font-style: normal; line-height: normal} --> </style> </head> <body bgcolor="#FFFFFF" text="#000000"> <?php $db = mysql_connect("0.0.0.0","cepayne","@#$%DZ"); mysql_select_db("employes",$db); // display individual record if($EMID) { $result =mysql_query("SELECT * FROM emply_info WHERE EMID=$EMID",$db); $myrow = mysql_fetch_array($result); //The Table print "<table width='700' border='1' cellpadding='0' cellspacing='0' bordercolor='#333333'>\n"; print "<tr>\n"; print "<td>\n"; // The Inner Table $Lname = $myrow[Lname]; $Fname = $myrow[Fname]; $MI = $myrow[MI]; $photoid = $myrow[photoid]; $Address = $myrow[Address]; $Address2 = $myrow[Address2]; $City = $myrow[City]; $ST = $myrow[ST]; $Zip = $myrow[Zip]; $Hphone = $myrow[Hphone]; $Cphone = $myrow[cphone]; $Email = $myrow[Email]; $Hemail = $myrow[Hemail]; $UserID = $myrow[UserID]; $BadgeID = $myrow[BadgeID]; $DOB = $myrow[DOB]; $Sdate = $myrow[Sdate]; $Tdate = $myrow[Tdate]; print "<table width='100%' border='0'>\n"; print "<tr>\n"; print "<td width='12%'><strong>Name:</strong></td>\n"; print "<td width='1%'> </td>\n"; print "<td width='14%'>$Lname</td>\n"; print "<td width='1%'> </td>\n"; print "<td width='12%'>$Fname</td>\n"; print "<td width='1%'> </td>\n"; print "<td width='23%'>$MI</td>\n"; print "<td width='38%' rowspan='10'><img src='emplypix/$photoid'></td>\n"; print "</tr>\n"; print "<tr>\n"; print "<td width='12%'>Address</td>\n"; print "<td width='1%'> </td>\n"; print "<td colspan='4'>$Address</td></td>\n"; print "<td width='23%'> </td>\n"; print "</tr>\n"; print "<tr>\n"; print "<td width='12%'> </td>\n"; print "<td width='1%'> </td>\n"; print "<td colspan='4'>$Address2</td>\n"; print "<td width='23%'> </td>\n"; print "</tr>\n"; print "<tr>\n"; print "<td width='12%'> </td>\n"; print "<td width='1%'> </td>\n"; print "<td colspan='4'>$City, $ST $Zip</td>\n"; print "<td width='23%'> </td>\n"; print "</tr>\n"; print "<tr>\n"; print "<td width='12%'>Home Phone</td>\n"; print "<td width='1%'> </td>\n"; print "<td width='14%'>$Hphone</td>\n"; print "<td width='1%'> </td>\n"; print "<td width='12%'>Cell Phone</td>\n"; print "<td width='1%'> </td>\n"; print "<td width='23%'>$Cphone</td>\n"; print "</tr>\n"; print "<tr>\n"; print "<td width='12%'>E-Mail</td>\n"; print "<td width='1%'> </td>\n"; print "<td width='14%'><a href=\"mailto:$Email\">$Email</a></td>\n"; print "<td width='1%'> </td>\n"; print "<td width='12%'>Home E-Mail</td>\n"; print "<td width='1%'> </td>\n"; print "<td width='23%'><a href='mailto:$Hemail'>$Hemail</a></td>\n"; print "</tr>\n"; print "<tr>\n"; print "<td width='12%'>User ID:</td>\n"; print "<td width='1%'> </td>\n"; print "<td width='14%'>$UserID</td>\n"; print "<td width='1%'> </td>\n"; print "<td width='12%'>BabgeID:</td>\n"; print "<td width='1%'> </td>\n"; print "<td width='23%'>$BadgeID</td>\n"; print "</tr>\n"; print "<tr>\n"; print "<td width='12%'> </td>\n"; print "<td width='1%'> </td>\n"; print "<td width='14%'> </td>\n"; print "<td width='1%'> </td>\n"; print "<td width='12%'> </td>\n"; print "<td width='1%'> </td>\n"; print "<td width='23%'> </td>\n"; print "</tr>\n"; print "<tr>\n"; print "<td width='12%'>Date of Birth:</td>\n"; print "<td width='1%'> </td>\n"; print "<td width='14%'>$DOB</td>\n"; print "<td width='1%'> </td>\n"; print "<td width='12%'>Start Date:</td>\n"; print "<td width='1%'> </td>\n"; print "<td width='23%'>$Sdate</td>\n"; print "</tr>\n"; print "<tr>\n"; print "<td width='12%'> </td>\n"; print "<td width='1%'> </td>\n"; print "<td width='14%'> </td>\n"; print "<td width='1%'> </td>\n"; print "<td width='12%'>Term Date</td>\n"; print "<td width='1%'> </td>\n"; print "<td width='23%'>$Tdate</td>\n"; print "</tr>\n"; print "</table>\n"; // The Inner End print "</td>\n"; print "</tr>\n"; print "</table>\n"; } else { //show Employee List # 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); if ($myrow = mysql_fetch_array($result)) { // display list if there are no records to display do { printf("<a href=\"%s?EMID=%s\">%s %s</a><br>\n", $PHP_SELF, $myrow[EMID],$myrow[Lname], $myrow[Fname]); } while ($myrow = mysql_fetch_array($result)); } else { // no record to display echo "Sorry no records were found!"; } } ?> </body> </html> ---------------------------------------------------------------------------- on 3/11/02 4:08 AM, liljim at [EMAIL PROTECTED] wrote: > 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. > > Hope that's of some help. > > > James > > "Chuck "Pup" Payne" <[EMAIL PROTECTED]> wrote in message > [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... >> 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 so a sort like the > example >> above. >> >> Chuck Payne >> Magi Design and Support >> >> >>> on 3/10/02 9:42 PM, Cary at [EMAIL PROTECTED] wrote: >>> >>>> At 08:24 PM 3/10/02, Chuck \"PUP\" Payne wrote: >>>>> Hi, >>>>> >>>>> I not a newie but I am not a pro at mysql either. I want to do a query > by >>>>> letter(a, b, c..ect.). Is there a simple way to do it. I am writing in > PHP. >>>>> So can someone please so me the how. >>>> >>>> >>>> I'm not totally sure what your looking for. If you could elaborate a > little >>>> I am sure that one of us could help you out. >>>> >>>> Cary >>>> >>>> >>>> >>> >> > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php