Changing letters to numbers?
Posted: Wed Aug 23, 2006 10:39 am
feyd | Please use
Thanks alot!!!
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
I have this script that list users in alphabethic order, but there is just 1 problem. I use the danish alphabet with the letters "Æ(ae), Ø(oe), Å(aa)". The problem is that it doesnt list those letters correct.
So my thourgt that if i changed the letters to numbers in an "array" it should be able to list them from 1 - 28, but the problem is that it doesnt seem to work. Can anybody help?Code: Select all
$query = "SELECT uid, name, 3d, 2d, link FROM users ORDER BY REPLACE(LOWER(name),'aa','å') ASC";
$result = mysql_query($query);
$names = array();
while($r = mysql_fetch_row($result)) {
$names[] = array('uid'=>$r[0],'name'=>$r[1],'3d'=>$r[2],'2d'=>$r[3],'link'=>$r[4]);
sort($array); }
$currLetter = array('A' => '1', 'B' => '2', 'C' => '3', 'D' => '4', 'E' => '5', 'F' => '6', 'G' => '7', 'H' => '8', 'I' => '9', 'J' => '10', 'K' => '11', 'L' => '12', 'M' => '13', 'N' => '14', 'O' => '15', 'P' => '16', 'Q' => '17', 'R' => '18', 'S' => '19', 'T' => '20', 'U' => '21', 'V' => '22', 'W' => '23', 'X' => '24', 'Z' => '25', 'Æ' => '26', 'Ø' => '27', 'Aa' => '28', 'Å' => '28');
$numColumns = 4;
$numNames = mysql_num_rows($result);
$numNamesPerColumn = ceil($numNames/$numColumns);
?>
<table width="100%">
<tr>
<?php
$currLetter = '';
$c = 0;
for($i=0;$i<$numColumns;$i++) {
echo '<td width="25%" valign="top">';
for($x=0;$x<$numNamesPerColumn;$x++) {
if(!isset($names[$c])) { break; }
if($names[$c]['name']{0} != $currLetter) {
if($x!=0) { echo '<br>'; }
$letterimages = array('A' => '1', 'B' => '2', 'C' => '3', 'D' => '4', 'E' => '5', 'F' => '6', 'G' => '7', 'H' => '8', 'I' => '9', 'J' => '10', 'K' => '11', 'L' => '12', 'M' => '13', 'N' => '14', 'O' => '15', 'P' => '16', 'Q' => '17', 'R' => '18', 'S' => '19', 'T' => '20', 'U' => '21', 'V' => '22', 'W' => '23', 'X' => '24', 'Z' => '25', 'Æ' => '26', 'Ø' => '27', 'Å' => '28');
echo '<img src="img/letters/'.$letterimages[strtoupper($names[$c]['name']{0})].'.png" alt="" /><br>';
$currLetter = $names[$c]['name']{0};
}
echo '<a href="'.$names[$c]['link'].'">'.$names[$c]['name'].'</a>';
if($names[$c]['3d']=='yes') { echo ' <img src="img/3d.gif" width="10" height="10"
alt="" /> '; }
echo '<br>';
$c++;
}
echo '</td>';
}
?>feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
[quote="[url=http://forums.devnetwork.net/viewtopic.php?t=30037]Forum Rules[/url] Section 1.1"][b]1.[/b] Select the correct board for your query. Take some time to read the guidelines in the sticky topic.[/quote]