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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T02:38:59+00:00 2026-05-15T02:38:59+00:00

Im trying to implement the search feature in my website. when the search keyword

  • 0

Im trying to implement the search feature in my website.

when the search keyword is entered in the textbox, and the category combo is selected, the form will be Posted and the result will be shown on the same page.

what i want is to keep the selected category of the combo by default in the form after posted

For eg., If i select the category ‘Automobiles’ in the combo and click search, after form submit, the combo should show the automobiles as default selected option. Please help me. Any help will be appreciated

  • 1 1 Answer
  • 2 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-15T02:38:59+00:00Added an answer on May 15, 2026 at 2:38 am

    I assume you get categories from database.

    you should try:

    <?php
    
    $categories = $rows; //array from database
    foreach($rows as $row){
         if($row['name'] == $_POST['category']){
              $isSelected = ' selected="selected"'; // if the option submited in form is as same as this row we add the selected tag
         } else {
              $isSelected = ''; // else we remove any tag
         }
         echo "<option value='".$row['id']."'".$isSelected.">".$row['name']."</option>";
    }
    ?>
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to implement search result highlighting for pdfs in a web app. I
I am trying to implement an internal search for my website that can point
I'm trying to implement a live search for my website. One that identifies words,
I am trying to implement a feature similar to the "Related Questions" on Stackoverflow.
I'm trying to implement a feature similar to StackOverflow's tag feature. That a user
I am trying to implement a feature similar to the Related Questions on StackOverflow,
I'm trying to implement a search for my project , but i can't figure
I'm still trying to implement a search function into my Android app. So far
So I am trying to implement a search bar in my app and am
I'm trying to implement a multi threaded, recursive file search logic in Visual C++.

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.