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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T05:39:59+00:00 2026-06-01T05:39:59+00:00

I have created a PHP code to echo the following div <div id=main_catsel> <select

  • 0

I have created a PHP code to echo the following div

<div id="main_catsel">
<select id="maincat" >

    <option value="1">none</option>
    <option value="2">Computer</option>
    <option value="4">Refrigerator</option>
    <option value="13" selected="selected" >Grinder</option>
    <option value="21">Bed</option>

</select>
</div>

I am using the option values and name as result from query . But now the default result still shown first is according to the id not according to selected=”selected”. Can any one sugsest a solution for this. Cant remove the id ,because its needed for insertion.

  $maincat .='<div class="main_catsel">';
     $sqlmaincat = $ilance->db->query("SELECT
            cid FROM " . DB_PREFIX . "seller_profile 
            WHERE userid = '" . $uid . "'");
    $row = $ilance->db->fetch_array($sqlmaincat);
    $sqlcat = $ilance->db->query("SELECT
            cid,title_spa 
            FROM " . DB_PREFIX . "categories 
            WHERE parentid = '0'
            ");
         if ($ilance->db->num_rows($sqlcat) > 0)
         {
          $maincat .='<h2><select id="maincat">';
           while ($rows = $ilance->db->fetch_array($sqlcat))
            {  
             if($rows['cid']==$row['cid'])
             {
              $maincat .='<option selected="selected" value="'.$rows['cid'].'">'.$rows['title_spa'].'</option>';
              }
              else
              {
                $maincat .='<option value="'.$rows['cid'].'">'.$rows['title_spa'].'</option>';
                }
             }  
                $maincat .='</select></h2>';
       }
        $maincat .='</div>';
  • 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-01T05:40:01+00:00Added an answer on June 1, 2026 at 5:40 am

    What browser are you using?

    “On SGML and HTML” points out that some browsers only support the minimized form, i.e. selected rather than selected="selected".

    Or maybe you previously selected something, and your browser is remembering your choice. Try holding Shift and clicking the Reload button, or press Ctrl+F5.

    Or maybe the your browser is caching an older version of the page. Again Shift+Reload should help. Browser-specific details at Bypass your cache.

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

Sidebar

Related Questions

I have the following form in cakephp: <div class=quickcontactDisplay> <?php echo $form->create('Enquiry',array('action'=>'add','class'=>'quickcontact')); echo $form->hidden('visitor_id',
I have the following code for my login view: <?php echo $session->flash('auth'); echo $this->Form->create('User',
I have the following code in a php template called contact_us. I have created
I have created a php table like so: echo <table border = '0' cellpadding
I have created a PHP form which requires the user to select a postcode
I have the following pages: page1.php, page2.php and page3.php. Code in each of them
I have the following code... $stored_date = date_format(date_create('now'), 'Y-m-d H:i:s'); echo 'Stored date: '
I am using the following code, upload.php, to try to have someone upload a
i have the following PHP code: <?php ini_set( 'default_charset', 'UTF-8' ); mb_internal_encoding('UTF-8'); function labelValidate($label)
i have create a form (so it's PHP and HTML hybrid-code). it has ability

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.