etsted Posted April 11, 2014 Share Posted April 11, 2014 the function at the bottom is supposed to store both the value and name of the choosen argument, but only stores the name <body> <form action="hovedrett.php" method="post"> <select name="frett"> <option>rekkeplatte</option> <option>friske reker</option> </select> <br> <input type="submit" name="knapp" value="Neste"> </form> <?php $forrett = $_POST['frett']; function bevare($mat) { foreach($mat as $indeks => $verdi) { if( !strstr($indeks, "knapp")) { echo "<input type='hidden' name='$verdi' value='$indeks'> "; } // if } // foreach } bevare($forrett); ?></body> Link to comment Share on other sites More sharing options...
etsted Posted April 11, 2014 Author Share Posted April 11, 2014 it says Invalid argument supplied for foreach() Link to comment Share on other sites More sharing options...
thescientist Posted April 11, 2014 Share Posted April 11, 2014 read the manual on foreach then http://www.w3schools.com/Php/php_looping_for.asp http://www.php.net/manual/en/control-structures.foreach.php you need to pass it an array. You are just passing it a string (the value of the selected <option> tag). Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now