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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T16:42:11+00:00 2026-05-17T16:42:11+00:00

I am using php to build a change classifieds page right now. I use

  • 0

I am using php to build a “change classifieds” page right now.

I use Mysql as a db.

Currently I use PHP to fetch all mysql information about the classified, and then I output it like this:

  $table.="
   <select name='year' id='year'>
     <option id='2000' value='2000'>2000</option>
     <option id='2001' value='2001'>2001</option>
     <option id='2002' value='2002'>2002</option>
   </select>";

   echo $table;

I have a picture upload tool which submits the page to itself, and at the same time uploads the picture, and shows it at the bottom of the page. The problem is, whenever this is done, the user must fill in all information again, because they are “forgotten”.

I know about input type=”text” where you simply can do something like this:

   <input type="text" name="text" value="<?php echo $_POST['text'];?>">

but what about selects? Radios? etc?

What should I do here?

Thanks

  • 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-17T16:42:12+00:00Added an answer on May 17, 2026 at 4:42 pm

    For selects, it is a bit more intense you need to loop through the data and check if the value equals the selected value (at least that is the easiest to do). But you could apply a similar technique as seen with the checkbox / radio.

    <input type="radio" name="radio1" value="1" <?php echo (!empty($_POST['radio1']))?'checked':''?>> 
    <input type="checkbox" name="chkbox1" value="1" <?php echo (!empty($_POST['chkbox1']))?'checked':''?>>
    

    Since you are creating the table PHP side here is the code:

      $years = array('2000', '2001', '2002');
    
      $table .= "<select name='year' id='year'>";
      foreach ($years as $year) {
          $table .= "<option id='" . $year . "' value='" . $year . "' " . 
                (($_POST['year'] == $year)?'selected':'') . ">" . $year . "</option>\n";
      }
    
      $table.="</select>";
    

    Should get you on the right track for select statements. The ? and : make up the ternary operator which is a shortened if / else statement.

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

Sidebar

Related Questions

Using PHP and MySQL, I have a forum system I'm trying to build. What
Been using PHP/MySQL for a little while now, and I'm wondering if there are
I've been using PHP & MySQL for ages and am about to start using
I developed a simple PHP web page using Dream Weaver CS5 Version 11.0 Build
I am using PHP and jQuery to build an interactive timeline which needs to
I build a css file using PHP which allows me to easily customize the
I followed the following tutorial to build a multilingual webpage using php arrays: http://bytes.com/topic/php/answers/880915-how-develop-multi-lingual-websites-php
I am using jQuery to build an array of images from a php array.
A site I am working on that is built using PHP is sometimes showing
I'm working on something that was built on a PC set-up using php and

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.