Some help please, I'm trying for a couple of days now and I don't get the code to work the way I want it to work. What I want is a query that provides data for an array (this works) that is displayed on screen by a foreach in a dropdownbox (this works also), but when I put it all in to a function it doesn't work anymore. And it doesn't matter where I put the query. So if one can help, one would be very happy. Here is the code that's causing the problem: if($result) { $knsa_nr_array=array(); while ($row = mysql_fetch_object($result)) { $knsa_nr = ($row -> knsa_nr); $vnaam = ($row -> vnaam); $anaam = ($row -> anaam); $voorvoegsel = ($row -> voorvoegsel); $knsa_nr_array[] = array("$anaam, $vnaam $voorvoegsel"=>"$knsa_nr") + $knsa_nr_array; $knsa_nr_array[] = array("Naam"=>"00") + $knsa_nr_array; } } function show_form($knsa_nr="", $schiet_dd_dag="", $schiet_dd_maand="", $schiet_dd_jaar="", $diopler="", $diopler_tot="", $kkg="", $kkg_tot="", $kkp="", $kkp_tot="") { ?> <form name="schietstand_toevoegen" method="post" action="standen_add.php"> <table width="750" bordercolor="#000000" border="1"> <tr><td width="350">KNSA nummer</td> <td width="400"> <? if ($_GET[knsa_nr]) { ?> <input type="text" name="knsa_nr" value="<? echo $_GET[knsa_nr] ?>" size="10" onFocus="blur()"> <? } else { foreach($knsa_nr_array as $knsa_nr_show => $knsa_nr_input) { ?> <option value="<? echo $knsa_nr_input?>" <? if($knsa_nr_input==$knsa_nr) { ?> selected <? } ?> onfocus="blur()"> <? echo $knsa_nr_show ?> </option> <? } } ?> </td> PHP: It doesn't matter where I place this code, every time I adjust the code I get the following error-message: and this reverse to the following line I can get this code to work without the function show_form(), but I need it incase a invalid value is inserted. Or can I get it to work without the show_form() function with pasting the values in a string?? If so how do I get multiple values in the <a href>? Thanxs
Vars are only local to the function, declare the the db array within the function ie global $knsa_nr_array;
Thanxs That was indeed the trick after a few tries. I set and it worked like a charm. How stupid of myself, didn't imagine I could forget that Cheers