Jump to content

Ordering recordsets by multiple fields


Recommended Posts

Hi,

I am trying to sort the table where I store a date in separate cells (year, month, day). When listing the ouput I want the date to be sorted either in ASC or DESC order. However, only last column in the $column variable is sorted, no matter how many columns are included in the variable. In this case I end up with sorted days but the months are not sorted. This makes me think that I cannot sort on more than one criteria (column). Am I correct? Is there a way to sort the tables in Dreamweaver on more than one criteria? Please help. Below is the code with portions eliminated for clarity.

 

 

<?php
$sort = ($_GET['sort']);
$column = ($_GET['column']);
if (!$sort)
{
 $sort = "ASC";
}
if (!$column)
{
$column = "eventinfo.eventyear,eventinfo.eventmonth,eventinfo.eventday";
}

mysql_select_db($database, $connection);
$query_rsEventData = "SELECT eventinfo.eventmonth, eventinfo.eventday, eventinfo.eventyear FROM eventinfo WHERE ... ORDER BY $column $sort";

if ($sort == "ASC")
{
$sort = "DESC";
}
else
{
$sort = "ASC";
}
?>


<a href = "file.php?sort=<?php echo "$sort";?>&column=eventinfo.eventyear,eventinfo.eventmonth,eventinfo.eventday">

 

 

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.