sorting street names

I am trying to sort street names in a more natural way.

Ex:
1st st
10th st
11th st
2nd st
20th st
3rd st
W 2nd st
W 1st st
N 1st st
Should Be :
1st st
N 1st st
W 1st st
2nd st
W 2nd st
3rd st
10th st
11th st
20th st

This is my code
[php]<?php

$ctid = $_REQUEST[‘ctid’];
$page = “getStreets”;

require(‘i5db2connect.php’);

$city = strtoupper($_REQUEST[‘city’]);

$sql_what = “SELECT distinct pistrt”;
$sql_from = " FROM $Libr.rlprop";
$sql_where = " WHERE picity = ‘$city’ and pistrt != ‘’ “;
$sql_order = " ORDER BY pistrt”;

$sql_stmt = “$sql_what $sql_from $sql_where $sql_order”;
$stmt = db2_exec($i5link,$sql_stmt)
or die(“Failed query:”.db2_stmt_error().":".db2_stmt_errormsg());

echo “<select width=“100px” id=“streetsSelect”>”;

while ($row = db2_fetch_assoc($stmt)) {

$street = ucfirst(strtolower($row[‘PISTRT’]));

echo “<option onclick=“showHouse();” value=”$street">".$street;

}

echo “”;

db2_close($i5link);

?>[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service