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 8020617
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T21:44:17+00:00 2026-06-04T21:44:17+00:00

I have a PHP-based sorting method with a drop-down menu to sort rows. It

  • 0

I have a PHP-based sorting method with a drop-down menu to sort rows. It works. I have another sorting links to sort id and title. It also works. But together they do not work.

When I sort (say by title) using links, the result gets sorted by title, then if I sort rows using my drop-down menu, rows get sorted, but the result gets set back to the default of id sort.

My sorting code for ID and title:

    if ($orderby == 'title' && $sortby == 'asc')
{echo " <li id='scurrent'><a href='?rpp=$rowsperpage&order=title&sort=asc'>title-asc:</a></li> ";}
else {echo " <li><a href='?rpp=$rowsperpage&order=title&sort=asc'>title-asc:</a></li> ";}   

if ($orderby == 'title' && $sortby == 'desc')
{echo " <li id='scurrent'><a href='?rpp=$rowsperpage&order=title&sort=desc'>title-desc:</a></li> ";}
else {echo " <li><a href='?rpp=$rowsperpage&order=title&sort=desc'>title-desc:</a></li> ";} 

if ($orderby == 'id' && $sortby == 'asc')
{echo " <li id='scurrent'><a href='?rpp=$rowsperpage&order=id&sort=asc'>id-asc:</a></li> ";}
else {echo " <li><a href='?rpp=$rowsperpage&order=id&sort=asc'>id-asc:</a></li> ";}     

if ($orderby == 'id' && $sortby == 'desc')
{echo " <li id='scurrent'><a href='?rpp=$rowsperpage&order=id&sort=desc'>id-desc:</a></li> ";}
else {echo " <li><a href='?rpp=$rowsperpage&order=id&sort=desc'>id-desc:</a></li> ";} 
?>

My sorting codes for rows:

<form action="is-test.php" method="get">
<select name="rpp" onchange="this.form.submit()">    
<option value="10" <?php if ($rowsperpage == 10) echo 'selected="selected"' ?>>10</option>
<option value="20" <?php if ($rowsperpage == 20) echo 'selected="selected"' ?>>20</option>
<option value="30" <?php if ($rowsperpage == 30) echo 'selected="selected"' ?>>30</option>   
</select>
</form>    

This method passes only rows per page (rpp) into url. I want it to pass order, sort, and rpp. Is there a way to pass these multiple values in form fields.

  • 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-06-04T21:44:19+00:00Added an answer on June 4, 2026 at 9:44 pm

    Are you allowing the user to change ordering as well?

    If so, add another input for it of some input type.

    If not, add a hidden input <input type="hidden" name="sort" value="asc"> or simply have the options manipulate the URL and not submit a form.
    Another Stackoverflow solution has something that works really similarly to this: https://stackoverflow.com/a/1091005/319066

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

Sidebar

Related Questions

hi i have set up a php based form submission method for sorting rows
I have a PHP based form. It has a drop down list which fetches
HI i have a working php based pagination which works fine, but when i
I have PHP based web app that does calculations on a series of numbers
I have a PHP-based pagination system and it is working fine, I'm using GET
I have a PHP-based site with bookings/appointments stored in a MySQL database. I want
I have a php based system working perfectly since 2006, which has a backend
I have a PHP based application that I need to work on both a
I have a PHP script that creates other PHP files based on user input.
I'm have a PHP and MYSQL based newsfeed. To get new content, the user

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.