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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T03:20:48+00:00 2026-05-24T03:20:48+00:00

Sorry, I want to ask a newbie question :) I have PHP scripts like

  • 0

Sorry, I want to ask a newbie question 🙂

I have PHP scripts like this :

<select id="member">
 <?php
  $sql   = " select id,name from member order by name ";
  $query = mysql_query($sql);
  while($row=mysql_fetch_array($query))
  {             
 ?>
  <option value="<?php echo $row["id"]; ?>"><?php echo $row["name"]; ?></option>
 <?php
  }
 ?>                
</select>

then the result will be generating html like this

<select id="member">
 <option value="1">Jon Skeet</option>
 <option value="2">Marc Gravell</option>
 <option value="3">Darin Dimitrov</option>
</select>

my question is, actually I have 2 tables in mysql, first is member table and second member_invited table.
in member table:
id | name
—————
00 | Jon Skeet
01 | Marc Gravell
02 | Darin Dimitrov

then in member_invited table:
id | name
—————
00 | Jon Skeet
02 | Darin Dimitrov

within this two table
I want to make my list like this:
(look at class=”selected” is in option tag that member has invited)

<select id="member">
 <option value="1">Jon Skeet</option>
 <option value="2" class="selected">Marc Gravell</option>
 <option value="3" class="selected">Darin Dimitrov</option>
</select>

please feel free to using javascript or jquery,, or maybe I can solve it just by using PHP ?
many 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-24T03:20:49+00:00Added an answer on May 24, 2026 at 3:20 am

    you have to do it in MySQL with a join to member_invited table and then extend your while loop regarding is_invited flag from resultset

    <?php
      $sql = "SELECT x.id,x.name,IFNULL(y.id,0) AS is_invited FROM member x LEFT JOIN member_invited y ON x.id=y.id ORDER BY x.name";
      $query = mysql_query($sql);
      while($row=mysql_fetch_array($query))
      {             
    ?>
    <option value="<?php echo $row["id"]; ?>"<?php if ($row['is_invited']>0) { echo " class=\"selected\""; } ?>><?php echo $row["name"]; ?></option>
    <?php
      }
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm sorry to have to ask something like this but python's mechanize documentation seems
Sorry for the second newbie question, I'm a developer not a sysadmin so this
Sorry if this sounds like a really stupid question, but I need to make
Sorry to ask this as I thought I knew the answer, I want to
I'm really sorry. This must seem like an incredibly stupid question, but unless I
currently i'm studying MySQL, sorry for my newbie question. Here my question I have
I'm sorry, I don't know how to ask this question without giving you the
Sorry for constantly re-editing my question but looks like this is the only way
Sorry to ask such a question, but I've spent 1/2 hour on this and
sorry to have to ask, but I don't know what this term means, 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.