Jump to content

Arrange in number order


robrayner

Recommended Posts

Hi All

 

This was working fine until the rma number reached the 1000 mark and now it is putting all the 1000 numbers with the 1's so you have to scroll all the way down the list to find the latest number. Is there away to stop this from doing this?

 

$query1 = "SELECT DISTINCT RMA FROM rmatable where RMA like 'RMAD%' ORDER BY RMA DESC";

 

$result1 = mysql_query($query1);

$num_rows=mysql_num_rows($result1);

while ($row=mysql_fetch_array($result1))

{

$RMA = $row["RMA"];

$row_ID = "$RMA";

echo "<option value=\"$row_ID\">$row_ID</option>";

}

echo "</select>";

?>

 

Thanks

 

Rob.
Link to comment
Share on other sites

I actually had this problem one time and found the answer through google. But, the correct answer is the one above where you should change the data type to an integer field.

 

But if you don't want to you can add an ABS() to the order by column and it should order it as integers...

 

 

$query1 = "SELECT DISTINCT RMA FROM rmatable where RMA like 'RMAD%' ORDER BY ABS(RMA) DESC";
 
Link to comment
Share on other sites

The natsort($rma);  worked but now you have to scroll to the bottom to find the latest rma number is there a way you can get it to display like this

 

RMAD1000

RMAD999

RMAD998

and so on

 

Instead of

 

RMAD100

RMAD101

......

RMAD998

RMAD999

RMAD1000

 

Thanks

 

Rob

Link to comment
Share on other sites

How would i implement array_reverse into this

 

 

$query1 = "SELECT DISTINCT RMA FROM rmatable where RMA like 'RMAD%'";
 
 
$result1 = mysql_query($query1);
$num_rows=mysql_num_rows($result1);
while ($row=mysql_fetch_array($result1))
{
 
$RMA = $row["RMA"];
$row_ID = "$RMA";
natsort($RMA);
 
echo "<option value=\"$row_ID\">$row_ID</option>";
}
echo "</select>";
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.