Erik Price wrote: > what function is used to remove an array element from an array? Like > array_pop(), except one by which I can refer to the element by its > associative index rather than just the last element of the array.
> > > For more detail with what I'm doing, I have two versions of a <select> > listbox -- one that includes an <option> with selected="yes" (if the > user is calling this page from submitting a form). The other version is > for users who are NOT calling this page from submitting a form, i.e. for > the first time. > > I would like, in the first version (if ($formfilled)), to REMOVE the > element $temprow['div_name'] from the array $temprow so that it doesn't > appear a second time (in the WHILE loop), since it has already been > echoed above the WHILE loop. > > Is this even possible? I would do it another way. say you have all the possible choices in an array that come out of a database, and ypou want, if the user already selected one, this one to be selected, right? Then i would set the selected atribute only if the value out of the database is the same as the one submitted by the form: like this (omitting the surrounding html): $query= "select distinct * from sometable"; $result=mysql_query($query); // the select field is named selectfield, echo "<form name=\"myform\" action=\"$PHP_SELF\" Method=\"post\">"; echo "<select name=\"selectfield\">"; // the variable $selectfield is, if set the value submitted by the form $selectfield = $_POST["selectfield"]; while ($row=mysql_fetch_array($result)){ echo "<option"; // assuming the second element of this array holds your // choices then if($selectfield == $row[1]){ echo " selected"; } echo ">" . $row[1] . "</option>\n"; } echo "</select>" echo "<input type=\"submit\">\n"; echo "</form>"; i think this is a more straightforward solution for your problem... henning -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]