Jump to content

Natural order


Germaris

Recommended Posts

Hi there!

 

Where and how can I implement, in the code below, a natsort() function to get volume as:

 

1  2  3  10  12  21  23

 

instead of

 

1  10  12  2  21  23

 

Many thanks in advance for any help!

Regards,

 

Gerry

 

 

function papier($unlock) 
{
	GLOBAL $db;
	$table = "_library"; 
	$query =mysql_query("SELECT * FROM $table WHERE issued='1' ORDER BY volume DESC");
	if (!$query) {
		print "&contenu=Le serveur est indisponible.";
	}
	else {
		if ( mysql_num_rows( $query ) > 0 ) {
			while ($row = mysql_fetch_array( $query )) { 
				$flashstr .= "<font color='#000000'>"."<b>".$row ["mainTitle" ]."</b>"."</font>".", vol. ".$row ["volume" ].", n° ".$row ["section" ]."<font color='#FF0000'>".$row ["soldout" ]."</font>"."<br />";
			}
			print ("&instruction=blah-blah-blah"."&contenu=".urlencode(stripslashes($flashstr))) ;
		}
		else {
			print "&contenu=blah-blah-blah";
		}
	}
}

Link to comment
Share on other sites

DONE !

It works.

Thank you very much!

 

However, I have another problem...

 

In my real world query, I ask for "(...  ORDER by volume, section DESC");

Let me explain a bit:

 

volume stands for issues of a bi-annual magazine (twice a year)

 

section stands for parts of a volume

- 1 for a single issue (single priced)

- 2-3 for a double issue (double priced)

section also can be 1-2 and 3

 

When I ask for order like defined above, the descending sorting is good for volume but not for section.

For example, the result displays for volume 14 section 1 before 2-3.

It should be volume 14, section 2-3 then volume 14, section 1

 

How can I solve this?

The section column can't be an INT column...

 

 

 

 

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.