Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1095225
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T00:05:27+00:00 2026-05-17T00:05:27+00:00

I have a database that has two fields: current, and previous. Here is the

  • 0

I have a database that has two fields: current, and previous.

Here is the code:

                            <?
$username="*****";
$password="*****";
$database="******";

mysql_connect(localhost,$username,$password) or die("Unable to connect to server");
mysql_select_db($database) or die( "Unable to select database");

$query='SELECT * FROM tasks WHERE current=1 OR previous=1';
$result=mysql_query($query);
$num=mysql_num_rows($result); 

mysql_close();

?>

It then output it and manipulate it like this:

<div class="tasklist">
    <div class="currentProject">
    Current Project:
    </div>
<?
$i=0;

while ($i < $num) {
$title=mysql_result($result,$i,"Title");
$link=mysql_result($result,$i,"Weblink");
$description=mysql_result($result,$i,"Description");
$id=mysql_result($result,$i,"ID");
$howto=mysql_result($result,$i,"howto");
$blogpost=mysql_result($result,$i,"blogpost");
$done=mysql_result($result,$i,"done");
$current=mysql_result($result,$i,"current");
$previous=mysql_result($result,$i,"previous");

if ( $current == 1 ) {
    $current = "current";
} else {
    $current = "";
}

if ( $previous == 1 ) {
    $previous = "previous";
} else {
    $previous = "";
}

?>

    <div class="<? echo $done ?> task <? echo $id ?>" id="<? echo $current.$previous ?>">
            <div class="titleWrapper">
                <div class="title">
                    <a class="article"  href="<? echo $link ?>"><? echo $title ?></a>
                </div>
            </div>
    </div><BR>

<?
$i++;
}

echo "</div>";


?>

The problem is that since previous comes before current in the database, it outputs previous and then current.

Question:

How do I make sure to output current first, and then previous?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T00:05:27+00:00Added an answer on May 17, 2026 at 12:05 am

    Just append this to your query order by previous.

    It must work as long as current task registry has previous=0 and previous task registry has previous=1.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a database table that has two fields , date and name. I
I have a Play Framework (1.2.4) project with PlayMorphia that has two different database
I have a table in a database that contains two fields id name I
I have two databases on one machine that also has two different sites running
I have a database that has around 10k records and some of them contain
I have a database that has a table email_eml that stores 3 attributes name_eml,
I have a database that has 16 tables, but only four are relevant to
I have a database that has the following columns: ------------------- id|domain|hit_count ------------------- And I
I have a database that has node & nodetype tables. Nodes table NodeID ParentNodeID
I have a mysql database that has text stored in it with non encoded

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.