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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:55:03+00:00 2026-05-25T20:55:03+00:00

I am trying to load a mulitple select from the database to edit. I

  • 0

I am trying to load a mulitple select from the database to edit.

I am storing the original data in an imploded string (ie “4, 6, 8, 9”).

What I want to do is explode that string from the database, then have the values selected when the edit form is loaded. The values are Float, then 1-52.

Here is the code I have so far, but it does not select the values.

$listing->getWeeksAvail() is just a call that returns the WeeksAvail property in this case “4, 6, 8, 9)

<?php
$weeks_available = explode(",", $listing->getWeeksAvail());
if (in_array("Float", $weeks_available)) {
    echo " selected='selected'";
}
?>

>Float</option>
<?php
    for($float=0; $float<=52; $float++) {
        echo "<option value=\"$float\"";
        if (($listing instanceof listing) && $float == $listing->getWeeksAvail()) {
        echo " selected='selected'";
    }
        echo ">$float</option>\n";
}
  • 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-25T20:55:03+00:00Added an answer on May 25, 2026 at 8:55 pm

    The second part of your code should be like this:

    <?php
    for ($float=0; $float<=52; $float++) {
        echo "<option value=\"$float\"";
        if (in_array($float, $weeks_available))) {
        echo " selected='selected'";
        }
        echo ">$float</option>\n";
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to load a page that is basically an edit form inside a
I'm trying to test a SOCKS proxy that's under load from multiple machines. The
I'm trying to insert XML data into mysql database. Issue I'm having is that
I am trying to load multiple elements with the same name from XML into
When trying to load Microsoft.Xna.Framework.dll from any project, it throws a FileNotFoundException. The specified
I am am trying to load a SQL table from a flat file. The
I've been trying to load multiple files into a table, so that they would
I'm trying to use CheckBoxes within a GridView's TemplateField to select multiple entries from
If I'm trying to save a list of items I want to save that
I have a 200 x 30 png-24 image that I am trying to load

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.