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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T21:43:07+00:00 2026-06-01T21:43:07+00:00

Here is another one. Twice in the same day. I’m trying to set up

  • 0

Here is another one. Twice in the same day. I’m trying to set up 4 select boxes that shows a option selected based the values in Target1-4 if they are equal to the value of enSlot.

echo "<select id='target".$row['paSlot']."' size='1' style='width:90px;'>";
$query = "SELECT * FROM enemy WHERE enChar = ".$_SESSION['chNum']." ORDER BY enSlot";
$result1 = mysql_query($query, $_SESSION['connect']) or die('Error 150: '.mysql_error());
while ($row1 = mysql_fetch_array($result1)) {
    $s = "";
    if ($_GET['Target1'] == $row1['enSlot']) {
            $s = "selected='selected'";
    }
    if ($_GET['Target2'] == $row1['enSlot']) {
            $s = "selected='selected'";
    }
    if ($_GET['Target3'] == $row1['enSlot']) {
            $s = "selected='selected'";
    }
    if ($_GET['Target4'] == $row1['enSlot']) {
            $s = "selected='selected'";
    }
    echo "<option value=".$row1['enSlot']." ".$s.">".$row1['enSlot'].". ".$row1['enRace'];
}
echo "</select>";

I run it with this:

Target1 = 1, Target2 = 2, Target3 = 3, Target4 = 4
Enemy has 4 records, enSlot = 1 – 4

When it executes I get all 4 select boxes show the last value of Target4 being selected.

  • 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-01T21:43:09+00:00Added an answer on June 1, 2026 at 9:43 pm

    The problem is in your logic no matter which condition evaluates the value of $s always will be selected=selected… You may try this:

    while ($row1 = mysql_fetch_array($result1)) {
        foreach( $_GET[] as $target ) {
            if( $target == $row1['enSlot'] ) {
                echo "<option value=".$row1['enSlot']." selected=selected>".$row1['enSlot'].". ".$row1['enRace']."</option>";
            } else {
                echo "<option value=".$row1['enSlot'].">".$row1['enSlot'].". ".$row1['enRace']."</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 insert the contents of one map to another. Here is the
Here's another one for you to help me solve: I have an ASP.NET website
Here i am moving the whole li elements from one list to another list.What
here is the problem. I have one PC using VS2008 (SP1 ) and another
I must be retarded with searching, because here's another seemingly common problem that I
I have this code for adding selected items from one ListBox to another. How
I am trying to call a function in another .php file from this one
So here's another IE cross-compatibility issue. My website, www.zerozaku.com, is compatible with Chrome and
guys. Here's another sample script in VBScript. It opens internet explorer, navigates to google,
File: /home/USER/DIR/a http://www.here.is.a.hyper.link.net/ /home/USER/DIR/b http://www.here.is.another.hyper.link.net/ Need to remove all the odd lines in this

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.