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

  • SEARCH
  • Home
  • 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 6119713
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:35:06+00:00 2026-05-23T15:35:06+00:00

I have a post system in place <?php /** Display the results from the

  • 0

I have a post system in place

    <?php
/**
Display the results from the database
**/
$q = ("SELECT * FROM threads ORDER BY posted");
$r = mysql_query($q);

if(mysql_num_rows($r)>0): //table is non-empty
    while($row = mysql_fetch_assoc($r)):
        $net_vote = $row['votes_up'] - $row['votes_down']; //this is the net result of voting up and voting down
?>
<div class='entry'>
    <span class='link'>
        <?php echo $row['author']; ?>&nbsp;&nbsp;&nbsp;
        <?php $row['posted'] = date("jS M Y h:i",$row['posted']); echo $row['posted']; ?>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" data-text="<?php echo $row['message']; ?>">
        Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>
        <br/> 
        <div class='message'><?php echo $row['message']; ?><br/></div> 
            <?php echo "<a href='msg.php?id=$row[id]'/> Comments/Add comments $row[replies]</a>" ?> &nbsp;
        <?php echo "Likes: " . $row['votes_up'] . "&nbsp "; echo "Dislikes: " . $row['votes_down'] . "&nbsp"; ?>    
    </span>

    <span class='votes_count' id='votes_count<?php echo $row['id']; ?>'></span> 
    <span class='vote_buttons' id='vote_buttons<?php echo $row['id']; ?>'>
        <a href='javascript:;' class='vote_up' id='<?php echo $row['id']; ?>'></a>
        <a href='javascript:;' class='vote_down' id='<?php echo $row['id']; ?>'></a>

    <br/>
    </span>

</div>

<br/>
<?php
    endwhile;
endif;
?>

I want to add text that says ‘order by : Most recent | Most liked | least liked ‘
As you can see i think ive got it already posting most recent by defualt which is what i want.

But what i want also is when you click ‘Most liked’ & ‘least liked’ it sorts by ‘Vote_up’ ( likes) & ‘vote_down’ (dislikes) all on the same page and shows posts with most likes on them (most liked) and most dislike (least liked)

EDIT***

sorry my question is how can i add 2 functions that when on click sorts by ‘most liked’ and ‘least liked’

  • 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-23T15:35:07+00:00Added an answer on May 23, 2026 at 3:35 pm

    in html:

    <a href='script.php?order=recent'>Recent</a>
    <a href='script.php?order=liked'>Liked</a>
    ...
    

    in php:

    if ($_GET['order'] == 'recent') $order = "posted";
    elseif ($_GET['order'] == 'liked') $order = "smth";
    ...
    $q = "SELECT * FROM threads ORDER BY ".$order."";
    

    but actually it’s better to use some js framework (i prefer extjs for that) to sort the output on client side

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

Sidebar

Related Questions

I have tried this... Dim myMatches As String() = System.Text.RegularExpressions.Regex.Split(postRow.Item(Post), \b\#\b) But it is
I have a post html form, and the action is index.php, which is the
Ok, I have a role based permission system in place and would like admin's
I have a text area where the users of the system can post anything,
Heres what I'm trying to accomplish: I have a tagging system in place. Tags
i have this problem to find a particular xml node l have post this
http://demo.thethemefoundry.com/traction/#post-183 Which wordpress plugin is this, to have post image on the left side
I have to POST some parameters to a URL outside my network, and the
I have a post-compilation step that manipulates the Java bytecode of generated classes. I'd
I have a post-build event that runs some commands for a c# project. The

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.