Solved

Numeric Order

Posted on 2010-08-12
8
263 Views
Last Modified: 2012-05-10
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
0
Comment
Question by:justmelat
8 Comments
 
LVL 63

Expert Comment

by:Zvonko
Comment Utility
From the bubble "Click to sort" I read that you have some library function doing the sorting on browser side.
Show the html page source so we can see what you are using there.

0
 
LVL 16

Expert Comment

by:HackneyCab
Comment Utility
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.
0
 
LVL 24

Expert Comment

by:lenamtl
Comment Utility
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
0
 
LVL 108

Expert Comment

by:Ray Paseur
Comment Utility
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.
0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 19

Expert Comment

by:Michael701
Comment Utility
Please post the code segment that retrieves the data.
0
 
LVL 82

Expert Comment

by:leakim971
Comment Utility
0
 
LVL 1

Author Comment

by:justmelat
Comment Utility
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_SUBMITTED'],'y-m-d','m/d/y')?></td>
<td><?=$R[$key]['ANSWER']['Q_5']?></td>
<td><?=translateField($R[$key]['R_STATUS'])?></td>
</tr>

<?$i++;endforeach;endif;?>
</table>
0
 
LVL 19

Accepted Solution

by:
Michael701 earned 500 total points
Comment Utility
try using ksort() it will sort the array by key value.




if(is_array($R)):

ksort($R);

foreach ($R as $key=>$val):

Open in new window

0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

In this article you'll learn how to use Ajax calls within your CodeIgniter application. To explain this, I'll illustrate how to implement a simple contact form to allow visitors to send you an email through your web site.
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now