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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T10:56:17+00:00 2026-06-17T10:56:17+00:00

I am trying to retain the radio button that was checked by the user

  • 0

I am trying to retain the radio button that was checked by the user when they return to edit posting. I am having difficulty in the proper syntax to get this to work.

Prior to adding the if statement everything worked fine.

for($index=0; $index < $indexCount; $index++)
{
if (substr("$dirArray[$index]", 0, 1) != ".")
{
echo"<div class=\"imageselect\"><br><div class=\"imageselectholder\"><img src =\"server/php/files/".$me."/medium/" . $dirArray[$index] ." \" /><br></div><div class=\"imageselecttxt\">Check to use this image</div><div class=\"imageselectcheck\"><input type=\"radio\" name=\"fpi\" value=\"" . $dirArray[$index] ."\" .if($_SESSION['fpi'] == $dirArray[$index]) \"checked=\"checked\" \"/></div> </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-17T10:56:19+00:00Added an answer on June 17, 2026 at 10:56 am

    i would do it like this, also cleaned up your quotes:

    for($index = 0 ; $index<$indexCount ; $index++){
        if(substr("$dirArray[$index]",0,1)!="."){
            if($_SESSION['fpi']==$dirArray[$index]){
                $checked = ' checked="checked" ';
            }else{
                $checked = '';
            }
    
            echo '<div class="imageselect"><br><div class="imageselectholder">
            <img src ="server/php/files/'.$me.'/medium/'.$dirArray[$index].' " />
            <br></div>
            <div class="imageselecttxt">Check to use this image</div><div class="imageselectcheck">
            <input type="radio" name="fpi" value="'.$dirArray[$index].'" '.$checked.' "/></div> </div>';
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create a script that will retain a count, even when it
I'm trying to convert XML that is passed in, but retain the original xml
I am trying to get the hang of retain / release. I get that
I'm trying to build an array/object based on user-input to a form that has
I am trying to retain a selected value in the dropdown after posting the
I'm trying to get the rememberMe() function to remember users and retain sessions for
Trying to make this jQuery filter that uses .find case-insensitive. For example, when the
I'm trying to backup a folder (e.g) /web/sites to /backups/websites and retain attributes, etc.
After trying to access ivars using KVC, I have noticed that there was no
I am trying to create this dropdown box that slides down and has 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.