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 🙂
you have to do it in MySQL with a join to
member_invitedtable and then extend your while loop regardingis_invitedflag from resultset