Saturday 15 February 2014

php - how to compare values in two MySQL queries -



php - how to compare values in two MySQL queries -

i have team page contains list of team members , select list contains list of friends. select list, can select friends added team (members). now, want ensure friends team members don't show in select list.

i tried below nil showing in select list, supposed show details of 1 friend not part of team members.

the code

<form action="tmembers.php" method="post"> <select multiple="true" name="members[]" val id="member" class=""> <?php while($record5 = $stmt5->fetch()){ //gets ids friend list $friends[] = $record5['id']; //array containing ids of friends } $membersarray[] = $members['id']; //array containing ids of team members foreach ($friends $t) { if (in_array($t, $membersarray)) { continue; } ?> <option value="<?php echo $record5['id'] ; ?>"> <?php echo $record5['surname'];?> <?php echo $record5['firstname'] ; ?> </option> <?php } // end-foreach ?> </select> </br> <input type="submit" value="send invite" name="invite" class=""/> </form>

you're using $record5 variable outside while loop.

i'm assuming $members['id'] id beingness added $membersarray[]. if it's array itself, should utilize $membersarray[0] within foreach.

try this:

<form action="tmembers.php" method="post"> <select multiple="true" name="members[]" val id="member" class=""> <?php while($record5 = $stmt5->fetch()){ //gets ids friend list $friends[] = $record5; //array containing ids of friends } $membersarray[] = $members['id']; //array containing ids of team members foreach ($friends $t) { if (in_array($t['id'], $membersarray)) { continue; } ?> <option value="<?php echo $t['id'] ; ?>"> <?php echo $t['surname'];?> <?php echo $t['firstname'] ; ?> </option> <?php } // end-foreach ?> </select> </br> <input type="submit" value="send invite" name="invite" class=""/> </form>

php html mysql pdo

No comments:

Post a Comment