Re: [PHP] Re: ordered alpabeticaly list

2001-12-14 Thread Rodrigo Peres

Hi list,

I'm using this script to generate an alphabetical list of names, and a .gif
as separator. Thank's Gerard onorato for the code. But I'd like a help to
make something that I always have problem. At this moment my script outputs
a html table with 1 column, how can I make it outputs a 3 column table???
this is the code.

$ultletra = '';
$row = '';
while($resultado = $query-dados()) {
$curletra = $resultado['letra'];
if($curletra != $ultletra) {
$row .= tr\ntd\nimg src=\img/letras/$curletra.gif\
width=\24\ height=\24\\n/td\n/tr\n;
}
$row .= tda
href=\interna.php?cat=$resultado[Nome_Categoria]celebID=$resultado[CelebID
]\.$resultado['Nome_Artistico']./a/td\n;
$ultletra = $curletra;

}

Thank's in advance

Rodrigo


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Re: ordered alpabeticaly list

2001-12-13 Thread Rodrigo Peres

Thnk's Mike,

But what I really need is create a separation like this

ex:

A
ab...
ac..
ad..

B
be...
bee...
..

for all the names in my table

Thank's again 

Rodrigo



on 12/13/01 4:30 PM, Mike Eheler at [EMAIL PROTECTED] wrote:

 If I understand you correctly, you want to put a separator when the
 letter changes.
 
 Try this:
 
 $result = mysql_query('select name from people order by name');
 $lastletter = '';
 while ($data = mysql_fetch_array($result)) {
 $curletter = strtolower(substr($data['name'],0,1));
 if ($curletter != $lastletter) {
 // Put code to insert a separator here
 }
 // put code to display the name here
 $lastletter = $curletter;
 }
 
 Mike
 
 Rodrigo Peres wrote:
 
 Hi list,
 
 I have a mysql tables, with names on it. I'd like to select this names
 ordered by name and output it to a html in alphabetical order, but separates
 by letter, ex: a, names with a, b
 I've done the select, but I can't figure out how to output the respective
 letters separated.
 
 
 Thank's in advance
 
 Rodrigo Peres
 
 
 

-- 



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] Re: ordered alpabeticaly list

2001-12-13 Thread Gerard Onorato

Okay, haven't tested this but it should work.


I would let mysql do some of the work here. In your select add something
like

Something like

$result = mysql_query('select ucase(left(name,1)) as foo, name from userlist
order by name');

$lastletter = '';
while ($data = mysql_fetch_array($result)) {
 $curletter = ($data['foo']);
 if ($curletter != $lastletter) {
 echo(br . $curletter . br);
 }
echo($data['name'] . br);
$lastletter = $curletter;
}


As I say, I haven't tested this but it should work. Unless I stink... which
I often do.


-Original Message-
From: Rodrigo Peres [mailto:[EMAIL PROTECTED]]
Sent: Thursday, December 13, 2001 1:36 PM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] Re: ordered alpabeticaly list


Thnk's Mike,

But what I really need is create a separation like this

ex:

A
ab...
ac..
ad..

B
be...
bee...
..

for all the names in my table

Thank's again

Rodrigo



on 12/13/01 4:30 PM, Mike Eheler at [EMAIL PROTECTED] wrote:

 If I understand you correctly, you want to put a separator when the
 letter changes.

 Try this:

 $result = mysql_query('select name from people order by name');
 $lastletter = '';
 while ($data = mysql_fetch_array($result)) {
 $curletter = strtolower(substr($data['name'],0,1));
 if ($curletter != $lastletter) {
 // Put code to insert a separator here
 }
 // put code to display the name here
 $lastletter = $curletter;
 }

 Mike

 Rodrigo Peres wrote:

 Hi list,

 I have a mysql tables, with names on it. I'd like to select this names
 ordered by name and output it to a html in alphabetical order, but
separates
 by letter, ex: a, names with a, b
 I've done the select, but I can't figure out how to output the respective
 letters separated.


 Thank's in advance

 Rodrigo Peres




--



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]