colombian Posted March 29, 2008 Share Posted March 29, 2008 My basic problem, is that I cannot get the form to keep the values if there is an error on submission. My forms with local arrays work fine, and basically go like this: function time_hour($hour) { $hours = range(1,12); global $hour; //the form element name foreach ($hours as $h) { if $h == $hour) { $selected = "select='selected'";} else { $selected = ""; } echo "<option value ='{$h}' {$selected}>{$h}</option>"; } I don't have the code with me, but that is overall how it goes, and it works just fine. However, when I am trying it with values with the MySQL database, I just can't figure out how to get it to work. I can get the values fine, and display them fine, I just can't get the select to change appropriately after submission. Any help would be greatly appreciated. And I apologize for not having the specific non working code here with me, it's at work. But basically I query the database, and try to use a foreach $row as $value command and use something similar to the sample above, but it just refuses to keep those values. Thanks in advance. I have been working on this for a while without luck, and it should* be easy =/ Any links with good PHP form function could also help. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.