Page 1 of 1

array question

Posted: Tue Jul 20, 2004 10:03 pm
by John Cartwright
i have this array which fills the drop down menu

Code: Select all

<?php
					echo "	<select name='cal-level'>";
            			
						$levels = array("i","p","m","im","o", $_SESSION["admin"]["cal-level"]);
						$levels = array_unique($levels);	

						foreach ($levels as $level)
						{
							echo "<option>".$level."</option>";
						}
						
            	  echo "</select>
?>
And the session will have one of those depending on the database... the problem is i always want the session var to appear first in the drop down menu and have no idea how to do this

Posted: Tue Jul 20, 2004 10:07 pm
by nigma
1. make the session variable the first element in the array
2. print out the first element in the array (the session var)
3. use a loop that prints out every element in the array that is after the first element

??

Posted: Tue Jul 20, 2004 10:09 pm
by John Cartwright
wow i feel so stupid...

thanks enigma

edit

NIGMA!!!!!!!

Posted: Tue Jul 20, 2004 11:24 pm
by nigma
haha, nigma~!

but hey, at least we figured things out, who cares if you feel stupid :)