justmelat
asked on
Numeric Order
View the attached shot
How do I force the number ordering from1, 2, 3,4,5, 6 and so on instead of 1, 100, 101, 2, 200, 201, etc in my php application?
numberingORder.png
How do I force the number ordering from1, 2, 3,4,5, 6 and so on instead of 1, 100, 101, 2, 200, 201, etc in my php application?
numberingORder.png
If you have the numbers in an array, you can use a PHP function such as natsort:
http://uk.php.net/manual/en/function.natsort.php
This treats numbers as humans would.
http://uk.php.net/manual/en/function.natsort.php
This treats numbers as humans would.
Hi,
Some suggestion:
for the date I recommand using yyyy_mm_dd format
for other kind of number you can add an extra 0 in front of the number
001, 010 etc
Some suggestion:
for the date I recommand using yyyy_mm_dd format
for other kind of number you can add an extra 0 in front of the number
001, 010 etc
If the column named "Number" is actually a number, the query can use ORDER BY to get these in the right sequence. Look at the data type to see if it is INT or DECIMAL or some other numeric variant. I think INT is probably what you want.
If the column is not a number (like VARCHAR) you have a goofy data base design. But you can cast the value to an integer by adding zero to it during the SELECT statement.
If the column is not a number (like VARCHAR) you have a goofy data base design. But you can cast the value to an integer by adding zero to it during the SELECT statement.
Please post the code segment that retrieves the data.
ASKER
HI All
this is the code that spits out my list of jobs:
$i=0;
$R=getRequests();
if(is_array($R)):
foreach ($R as $key=>$val):
$bgc=getBGC($i);
?>
<tr bgcolor="<?=getBGC($i)?>">
<td><a href="#" onclick="getRequest('<?=$R [$key]['R_ NUMBER']?> ');return false;"><?=$key?></a></td>
<td><?=$R[$key]['ANSWER'][ 'Q_6']?></ td>
<td><?=$R[$key]['ANSWER'][ 'Q_7']?></ td>
<td><?=formatDate($R[$key] ['R_DATE_S UBMITTED'] ,'y-m-d',' m/d/y')?>< /td>
<td><?=$R[$key]['ANSWER'][ 'Q_5']?></ td>
<td><?=translateField($R[$ key]['R_ST ATUS'])?>< /td>
</tr>
<?$i++;endforeach;endif;?>
</table>
this is the code that spits out my list of jobs:
$i=0;
$R=getRequests();
if(is_array($R)):
foreach ($R as $key=>$val):
$bgc=getBGC($i);
?>
<tr bgcolor="<?=getBGC($i)?>">
<td><a href="#" onclick="getRequest('<?=$R
<td><?=$R[$key]['ANSWER'][
<td><?=$R[$key]['ANSWER'][
<td><?=formatDate($R[$key]
<td><?=$R[$key]['ANSWER'][
<td><?=translateField($R[$
</tr>
<?$i++;endforeach;endif;?>
</table>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Show the html page source so we can see what you are using there.