Page 1 of 1

default selection in a drop down box

Posted: Tue Feb 20, 2007 3:55 pm
by slash_gnr3k
hey,
im having a problem with drop down boxes

Code: Select all

<?php 
				
			include 'connect.php';
			$iterationno = 1;
			
			while($iterationno < 
				{

					$getalldishes = @mysql_query("SELECT name FROM dishes");
	
					if(!$getalldishes)
					{

						echo "fail";
				
					}


					echo "<p><select name = \"newdish\" size = 1>";

					while ($row = mysql_fetch_array($getalldishes))
						{
	
						$name = $row['name'];
						echo"<option value =\"{$row['name']}\">{$row['name']}</option>";
	
						}

					echo"</select></p>";
					$iterationno++;
				}


			?>
the above code selects all dish names from the database and puts them in 7 drop down boxes. every drop down box has the first database record displayed so therfore i have seven identical drop down boxes.

this php script is in a file called "editplanframe.php" which is opened through a link in a file called autoplan.php. autoplan.php also passes 7 parameters which are strings. what i want to know is how can i make the first box display the value of the first string passed as the default?

hope this makes sense. thanks

Posted: Tue Feb 20, 2007 4:29 pm
by feyd
During your loop you compare the value to the passed information.