Question : Tricky Looping for dropdown field

Hello,

I have some of this function working and have run into some problems when trying to mark as "selected" the option in a select box.
You can see below my code and where I am stumped I put **DON"T KNOW WHAT TO PUT HERE** in the if statement.

Any ideas would be appreciated.

Thanks.





1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
function show($id){

// query the articlestosites table to find sites that have been assigned the particular article
	$query1 = "SELECT * FROM articlestosites where articleid = '{$id}'";
	$q1 = mysql_query($query1);
	while($row1 = mysql_fetch_assoc($q1)) {
	 $newIDarray[]=$row1['siteid']; 
	}

		$result = mysql_query("SELECT * FROM sitedetails");
			while($row = mysql_fetch_array($result)) {
			$idd = $row['id'];
		if(!is_array($newIDarray)) { $newIDarray[] = ""; }	
				if(in_array($idd,$newIDarray)) {
					echo "<input CHECKED  type=checkbox name=site[] value=".$idd.">". $row["site"];
					}else{
					echo "<input type=checkbox name=site[] value=".$idd.">". $row["site"];
				}

				// do my business with the select box for articletype
					echo "<select name=type{$idd}>";
						$result2 = mysql_query("SELECT * FROM articletypes");
							while($row2 = mysql_fetch_array($result2)) {
								if (**DON"T KNOW WHAT TO PUT HERE**) {
								echo "<option SELECTED>{$row2["articletype"]}</option>";
								} else {
								echo "<option>{$row2["articletype"]}</option>";
								}
							}
					echo "</select><br>\n\r";


			}

} 

Answer : Tricky Looping for dropdown field

May this?
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
while($row2 = mysql_fetch_array($result2)) {  
                $query_check = "SELECT * FROM articlestosites where articleid = {$id} AND site_id = {$row['id']}";
                $result_check =  mysql_query($query_check);
                if(mysql_num_rows($result_check)){
                    echo "<option SELECTED>{$row2["articletype"]}</option>";
                }else{
                    echo "<option>{$row2["articletype"]}</option>";     
                }

        }
Random Solutions  
 
programming4us programming4us