proctk Posted August 7, 2007 Share Posted August 7, 2007 The below code populates a select option with names of members found in a mysql table if they are not a registered member. In another table wish list I have a query that could match the value of an item in the select option. If the values of the wish list query matches the value of a name in the select option then I want it to be selected. Any ideas how to do this <select name="familymember"> <option></option> <?php echo "<option value=".'"'.$_SESSION['fname'].' '.$_SESSION['lname'].'"'.">".$_SESSION['fname'].' '.$_SESSION['lname']."</option>"; //get siblings $get_sibling = mysql_query("SELECT * FROM Links L, sibling S WHERE L.User_id = '$user_id' AND S.sibling_id = L.sibling_id"); while($sibling_row = mysql_fetch_assoc($get_sibling )){ $siblingfirstname = $sibling_row['siblingfirstname']; $siblinglastname = $sibling_row['siblinglastname']; $siblingdob = $sibling_row['siblingdob']; $check_sibling = mysql_query("SELECT * FROM users WHERE first_name ='$siblingfirstname' AND DOB ='$siblingdob' AND last_name='$siblinglastname'"); $sibling_find = mysql_num_rows($check_sibling); if($sibling_find ==0) { echo "<option value=".'"' .$sibling_row['siblingfirstname'].' '. $sibling_row['siblinglastname'].'"'.">".$sibling_row['siblingfirstname'].' '. $sibling_row['siblinglastname'].'-'."Sibling"."</option>"; } } //get children $get_children = mysql_query("SELECT * FROM Links L, children C WHERE L.User_id = '$user_id' AND C.child_id = L.child_id"); while($child_row = mysql_fetch_assoc($get_children )){ $childfirstname = $child_row['childfirstname']; $childlastname = $child_row['childlastname']; $childdob = $child_row['childdob']; $check_child = mysql_query("SELECT * FROM users WHERE first_name ='$childfirstname' AND DOB ='$childdob' AND last_name='$childlastname'"); $child_find = mysql_num_rows($check_child); if($child_find ==0) { echo "<option value=".'"' .$child_row['childfirstname'].' '. $child_row['childlastname'].'"'.">".$child_row['childfirstname'].' '. $child_row['childlastname'].'-'."Child"."</option>"; } } //get parents $get_parent = mysql_query("SELECT * FROM Links L, parent P WHERE L.User_id = '$user_id' AND P.parent_id = L.parent_id"); while($parent_row = mysql_fetch_assoc($get_parent)){ $parentfirstname = $parent_row['parentfirstname']; $parentlastname = $parent_row['parentlastname']; $parentdob = $parent_row['parentdob']; $check_parent = mysql_query("SELECT * FROM users WHERE first_name ='$parentfirstname' AND DOB ='$parentdob' AND last_name='$parentlastname'"); $parent_find = mysql_num_rows($check_parent); if($parent_find ==0) { echo "<option value=".'"' .$parent_row['parentfirstname'].' '. $parent_row['parentlastname'].'"'.">".$parent_row['parentfirstname'].' '. $parent_row['parentlastname'].'-'."Parent"."</option>"; } } //get Spouse $get_spouse = mysql_query("SELECT * FROM users WHERE user_id = '$user_id'"); while($spouse_row = mysql_fetch_assoc($get_spouse)){ $spousefirstname = $spouse_row['spousefirstname']; $spouselastname = $spouse_row['spouselastname']; $spousedob = $spouse_row['spousedob']; $check_spouse = mysql_query("SELECT * FROM users WHERE first_name ='$spousefirstname' AND DOB ='$spousedob' AND last_name='$spouselastname'"); $spouse_find = mysql_num_rows($check_spouse); if($spouse_find ==0) { echo "<option value=".'"' .$spouse_row['spousefirstname'].' '. $spouse_row['spouselastname'].'"'.">".$spouse_row['spousefirstname'].' '. $spouse_row['spouselastname'].'-'."Spouse"."</option>"; } } ?> </select> Link to comment https://forums.phpfreaks.com/topic/63638-select-found-value/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.